Modulation is a change of key in a musical piece. But, a modulation doesn’t necessarily change the key signature (unless a substantial amount of the composition switches from one key to another). Modulation or changing key is a transition from minor to major or major to minor. This phenomenon occurs in all types of genres but is quite common in classical music and film scores. Modulation creates a change in mood, from melancholy or foreboding to cheerful or uplifting. (Think of a movie. When a scene transitions from dark and scary to light and happy.)
Modulation is generally done through one of two means: pivoting or phrase/abruptly. Pivot chord modulation uses a home key or a common chord to go from one key to another. For instance, G Major to D Major. G Major consists of G, C, and D, while D Major consists of D, G, and A. The two commonalities are G and D. So, either G or D can be used as the pivot chords. The pivot chord modulation works best with closely related keys or keys that only contain a few different sharps and flats.
Phrase modulation or abrupt modulation refers to a sudden change of key. Phrase modulation or abrupt modulation often transitions from a single tone or semitone. This is ubiquitous in pop music and is often used to create a specific sensation, such as an exciting ending. For example, transitioning quickly from A Major to B Major or even a bigger change, such as A Major to D Major.