Whipping is an art form, and not just for the sadomasochists.
Whipping is best used in the following situations:
You have an emergency military need
You need to complete something quicker
You have excess unhappy population
You want to use the magic of whip overflow
In general, you want to use the whip so that your happiness situation is better or at least no worse than it was before you whipped.
Generally, you also want to use the whip so that your city will be able to regrow. Using the whip without food production and/or a granary to regrow is costly in the long run. Because the food in your "food bar" remains after whipping, a lot of folks like to whip when the food bar is high, allowing the city to quickly regrow (especially if the city has a granary).
Sometimes, however, you have the opposite problem, especially if you are using the whip to eliminate unhappy citizens. You whip a high-growth city, and it grows right back to the size it was, with one more unhappy face. What to do? Try whipping a happiness building (temple, etc.), or whip something that uses more than one population. Another tactic is to whip and then start building a worker or settler, which halts city growth.
Whip overflow is whipping a project that you have almost completed. You lose the population point but the excess ("wasted") hammers from using the whip go into your next project.
Whipping starts to become counterproductive at higher population levels, due to the ever-increasing amount of food it takes to grow bigger. You therefore suffer more lost production due to the fact that it takes you longer to grow back to that production level. Once you have Hereditary Rule, managing happiness is a matter of garrisoning enough cheap troops, and your bigger cities' production rates will be generally better than what you can get from whipping.
Hope that helps.