The "correct" usage of key can be context dependent, but the general rule would be to stay IN key.
To modulate (the nerd term for fluctuate/change) you need smooth voice leading; it can make even the wildest changes seamless.
However, certain chords "want" to go to others.
For example, if I am on the G chord in the key of G major, modulating to C major or A minor would be a good choice, because it is not only a chord shared by those keys, but it is the dominant V chord of C major and the VII of A minor. A very strong sense of "pull"
Should you modulate? Well, it's up to you of course, but it definitely can make your piece more interesting.
Every scale or mode presents its own assortment of major and minor harmonies.
If you have a C note, and you're using the C major scale, you have three obvious choices: the C major chord, the F major chord, and A minor because the note "C" is present in all three.
There are of course other options, but that is the basic idea.