I have lost a city or two here and there in my games, but it generally isn't more than a nuisance for me, so maybe I'm doing some things you guys aren't. First off, here are the things that effect city defection:
1) Proximity to capitol (both yours and theirs) - A huge factor, according to Soren.
2) Culture the enemy has accumulated in the city vs. culture you have accumulated
3) Overall Culture
4) Happiness (or lack thereof)
5) Military units to quell resistance (this is clearly the least important, as I have held cities that were resisting w/o any units in them).
1st off, understand that if you capture a large enemy city right next to their capitol, the odds are (even if your overall culture blows theirs out of the water) that you will lose the city. If there is no reason to keep such a city (such as a key wonder), BURN IT. If you absolutely must keep it, for whatever reason, starve the hell out of it while it's in resistance - make everyone entertainers - this will drop the population and make it easier to control. Once it begins to grow again, the citizens will be of your nationality. Use beat up or older units to garrison it (with the exception of ONE good defender to hold vs. counterattacks). Keep the bulk of your army out of there, cut the roads so the enemy can't counterattack as readily, and be ready to re-take it if it defects.
If you are planning on conquering - plan ahead. You may need more units than you think. This is because you may lose some. Use bombard units (cannon/artillery). Even if you don't really need to from a military standpoint, these units will knock population points off of the target city. Smaller cities are easier to control. Also, stacking offensive units in a newly captured city is a bad idea.
Rushbuilding temples/cathedrals/libaries/universities as soon as resistance ends is fairly obvious.
Go after the capitol. When you destroy an enemy capitol, it moves to their largest remaining city. If this is further away from a city you actually want to take and keep, you have aided your cause.
Generally, my rule of thumb is this: unless a given city is going to be relatively easy to keep (fairly close to my capitol, small in size, close to other cities of mine w/strong culture, etc.), I raze it. I almost always raze capitols - this does bad, bad things to the enemy's culture. This does make for quite a bit of razing late in the game. Early on, you are often conquering close to home, and thus the cities are easier to keep. I have taken to bringing settlers along for my wars in order to build new cities on or near the shattered ruins of the cities I raze.
-Arrian