This is a good article on shifting.
http://www.sheldonbrown.com/gears.html
I shift so that I can maintain a comfortable cadence, which is around 90 rpm. If I'm standing up, I'll shift up one or two so my cadence is around 70. While climbing my cadence may drop a bit, but if I'm going hard on a climb it's nice to mix the cadence up between 85-105.
I normally shift down when coming to a stop. That way I don't have to start in a high gear.