Use a primer if a surface has never been painted before, if you are using a different type of paint (especially important if the old paint is oil and the new is latex!) or you are painting a vastly different color (and, like miasmom said, use tinted primer for a dark color). If the surface is ‘slick’, use a special high-adhesion primer. For metals, use metal primer and paint. In my experience, primer is cheaper than paint in the long run, and the paint does go on better and look nicer afterwards.
Also wanted to add: buy good primer and good paint. I like Sherwin Williams best, much better than what I used to buy at Lowes or Home Depot!