Modulation is the method of moving from one key to another and is commonly used to create interest and to help works form a sense of structure.
Once the music has modulated, often a [perfect] cadence in the new key helps to confirm the change of key.