It is usually recommended to sit and get a nice pace going on a climb, so that you can conserve energy and finish with enough energy to get back into the regular flow when you're done.
It's good to stand and go hard on a climb when either:
- You know how long the climb is, and you know how much energy you can spend and where, or
- Your attacking someone in a race, or trying to set the pace really high to tire others out.
In any case, standing and "mashing" wastes about 5% more energy than just spinning and enjoying the pain. You will be tempted to do that, but it doesn't yield any great benefits.
Hope that helps!