I think you really have to micromanage to whip effectively. There are very few hard-and-fast rules of thumb that you can use. Some stuff for a slavemaster to consider (summarizing some of the points above)
Good things about the whip:
1) Whipping converts food to hammers at a rate which is usually a good deal. Once you've got your granary built in a city of size 4-6, you can get two hammers per food.
2) Whipping gets you instant results. A granary or settler or unit NOW may be much more valuable than if you had to wait for it.
3) Whipping can remove excess population if it isn't helping you (and probably hurting)
Bad things about the whip:
4) Unhappiness penalty
5) Lower population while growing back to max population
6) The slavery civic makes you vulnerable to revolts in your capital, and will eventually cause emancipation unhappiness
So as with all things, the goal is to maximize the positive aspects of whipping while mitigating the negatives.
What sort of city is good for whipping?
Most cities should whip as often as possible. If you're smart, you found all your cities with a couple of food resources, because you want them to grow quickly. But once they grow to their max size, you don't need so much food. Hence the whip. The only exception to this is cities which were founded to gather resources--that polar city in the middle of 6 beavers and a silver mine. You should make every effort to get some food (fish) in that city's fat cross, but sometimes you can't. Or sometimes you get a city with mediocre food surplus tiles (one cow or something) and a bunch of mines. Such a city will take a long time to grow. Once it is grown, it will give you lots of production and little or no food excess--so positive #1 (efficient translation of food to hammers) gets overcome by negative point #5 (you are stuck at lower population while growing back). You will only whip on the rare occasion when positive #2 (timeliness of whip production) comes into play. You have to judge this by game situation. For example, if I'm playing on an archipelago with the Dutch, virtually every city of sufficient size (even those with a mediocre food excess) will whip a dike the turn after I get access to them. It rarely matters if a city could build it more efficiently the slow way. Having to wait for that dike would more than offset any gains in efficiency.
How do I whip? Some whips are situational (like my dike whipping or whipping out the last couple units of an army or whipping out a couple caravels the turn they are available). You whip to produce something you urgently need. But most whips go on a timetable--the whip cycle. You whip every 10 turns (or 30 on marathon or whatever) on the turn that the unhappiness from the last whip wears off. Some cities (like my mediocre food--high production example) can't whip this often. But most of your cities should if you are smart and found them with food in mind. So whip unhappiness is the limiting factor. This means that for a city with enough food, THE ABILITY TO GET OVER WHIP UNHAPPINESS IS A VALUABLE ASSET. If you ever wear off unhappiness and don't whip again, you are wasting this asset. If you have grown to your happy cap (or have grown enough that you are working mediocre tiles or are having health problems) and there is anything remotely useful that you could whip, you should whip it as soon as the previous whip unhappiness is up.
Is it okay to stack up whip unhappiness?
Sure, if you have plenty of sources of happiness and you have infrastructure you need to build. This typically happens later in the game when you have lots of happy resources, so a new city isn't going to be bumping against the cap. Such a new city should whip (or chop if forests are available) its granary, forge, and other needed infrastructre just as quickly as its food supply will allow. Sometimes, charasmatic leaders starting with happiness resources in the initial BFC can stack whips from the start. It's situational. One other source of whip unhappiness is random events. Sometimes a fire will cause unhappiness. This stacks with the unhappiness from your whips (and therefore costs you one application of the whip for cities that are on the cycle). Keep this in mind when you get the "herbal medicine event". If you get this before you start whipping (get bronze working), it is a wonderful, wonderful event with almost no downside. But if you are already into whipping (or worse, have cities with a couple unhappiness stacked up), you need to think twice about putting two more whips on the stack. Even though 2 health forever in every city is awesome, it may not be worth it if it denies you 2 applications of the whip and/or keeps you below your ideal population.
What should I whip? Game situation dictates this of course, but for cities "on the cycle" you want them to grow back to max population in exactly the time it takes for unhappiness to wear off. Mega-seafood cities grow back faster than this, so you need to build workers/settlers once you get back to the happiness limit. Therefore, you whip your infrastructure. Cities with somewhat less food should build the infrastructure while growing back to happiness cap and then whip workers/settlers. Sometimes, cities are in between and do a little bit of both. Remember, you can and should change builds sometimes. Build a unit or building while you are growing and then switch to a settler once you have grown. Once the whip cycle has worn off, go back and whip the building. Just be aware of the time it takes for items in the queue to start decaying. It varies by speed. Units start decaying quicker than buildings, and wonders don't decay for a long time. Don't leave stuff in the queue so long you lose hammers.
Can I whip wonders?
You can, but you incur a penalty. Generally speaking, therefore, your city should spend its turns building the wonder manually and use its whip cycles (assuming it has enough food to be on the cycle) on infrastructure or something else. Note that you there is no penalty for whip overflow being applied to the wonder. If you want to micromanage, you can use this to your advantage by maximizing the overflow and finish your wonder quicker than you would have by leaving the city alone. I often count up hammers and do a whip just a few turns before the wonder would be done. I time it so the wonder finishes (using the overflow) the turn after the whip. All that said, sometimes, there is something to be said for flat-out whipping the wonder. If the wonder is going to give you huge immediate benefit (pyramids in a civ that needs happiness ASAP), whip it. If you think you might lose the race to a wonder (and/or are a cheater/reloader), whipping the wonder can save you the turns needed to win the race.
Mid/late game new cities build order.
With rare exceptions, whip/chop the granary first. The granary is essential to regrowth and makes subsequent whips twice as effective.
Build the forge next, because it gets you a 25% bonus on subsequent whips.
After that, you may want a lighthouse or a library or a harbor. Rarely, I will insert a lighthouse before the granary or forge on an island city with only seafood. Sometimes, the situation will require you to whip a culture building if you don't have religion/creativity/stonehenge.
Whipping is great on newly-captured cities. Whipping a forge immediately cuts down the excess population that is probably unhappy. Late-game, if you have enough extra folks, you can even whip a factory. Whip the big things first before the little ones of course (because starvation combined with little whips may leave you unable to whip the big stuff, so do the big stuff first). Whipping kills citizens of the foreign nationality, but when they grow back, they are your nationality. So you accomplish ethnic cleansing while rebuilding needed infrastructure--a real win/win. (EDIT--Dave says ethnic cleansing doesn't work that way anymore--you have to build culture. I'll have to check, but he's probably right).
As for point #6 (slave revolts), mostly you just have to accept them as a cost of running the great civic that is slavery. But if you are spiritual, you can mostly dodge it. Time your whip cycles so that all your cities whip at once. Then you can spend most of your time in another civic (emancipation when it's available), and minimize the downsides of being in slavery. Same goes for golden ages of course or if you build the Cristo Redentor. Also, don't go into slavery until you are ready to start whipping (although that's usually right away, it may not be)
I could probably write more, but that's good for now.