The theory you asked for can be found in:
http://en.wikipedia.org/wiki/Modulate_(music)
http://en.wikipedia.org/wiki/Perfect_authentic_cadence
I'll try to add something more practical. There are many good ways to go to a new key. Important is that you deliberately choose between going for a natural flow or a suprise.
One of the major problems is: how much space do you have in terms of bars and beats, taking the tempo into account. If you move too fast, the modulation might lack natural touch.
At the end of an average song with a 16-bar chorus you usally land on beat 1 of the bar before last. Very likely the tempo forces you to modulate on a speed of two chords per bar, so in theory you have three steps available before landng on the I of the new key. In many cases you'll chose a ii (or IV) - V7 - I sequence in the new key.
This is much like what Ed Fuqua explained.
Say, you would like to go from C to E.
| C - | A9 B7 | E This is a
chromatic modulation, because on the A9 chord we already have the note c# that is not in the C major scale. a softer, more natural way (for a sweet song) could therefore be to use Am or Am7 instead of A9.
In the example you even have room for an extra step, like:
| C G#dim | A9 B7 | E
It's important to make use of both scale-like voicings and notes that keep throughout different chords. In the second example, the root notes of the chord would make a nice voicing for the bass. The reason I wrote A9 instead of A7 (which is also good) is that another voice (a horn, top note on the keyboard, whatever), could play the note b all through the key change. These two voicings would give a very compulsive flow. If you want that, of course.
The extra step (G#dim in the example), should best be a chord that could occur in both old and new key. G#dim is also Abdim, Ddim, Fdim, Bdim, chords you might encounter in the key of C. Dim chords are often good candidates to be used in modulations. The same goes for augmented (+5) chords. After
renaming them, they suddenly are plausible in the new key. This is called
enharmonic modulation. Beside dims and +5 chords, there are more possibilities. To use those serious study of harmony is necessary, because they will only work with correct voicing.
Should you need another extra step for a really sweet key change, you might consider to not let the melody end on the old key major (or minor) chord, but to use that point to already start the modulation.
Very sophisticated is to choose a common chord that's already present in somewhere in the rest of the song.
Both sweet and surprising is if you modulate
in the middle of the song, where a series of chords suddenly is made to lead somwhere else. Especially useful for ballads.
Important notice: if you take more steps for a key change, you might be tempted to follow the circle of fourths for a while, like, going from C to G:
C E7 | A7 D7 | G
The more natural solution is to mix minor and major chords:
C E7 | Am D7 | G or C Em | Am D7 | G
This story is getting much longer than I thought...
Then we have the slope method, moving to the new key in a chromatice scale of major chords (from C to Ab):
C B7 | Bb7 A7 | Ab This is ugly guitar stuff. Upward guitar slope is even more ugly...
The bass line c - b - bb -a - ab in the example is OK, but
mixing the nature of the chords:
C Em | Gdim Eb7b5 | Ab
And.. there is the blunt method to change key in one go. Not always a bad surprise! Sometimes forced if you don't have room for more chords. Works for changes that are:
1. a major third up or down (good!)
2. a whole or a half step up (so and so).
A final note from the bass player's perspective. The basic bass progression during a modulation should best be confined to:
1. whole and half steps up or down
2. 4th up (or 5th down), especially the last jump right before the new key.
Disclaimer: this is all just advice, not rule. In the end, there's only your own good taste that rules.
Have fun!