I used to castle queenside liberally, particularly when playing against a black kingside fianchetto to attack by advancing my kingside pawns. But as I've improved and run into better players I've landed my king into hot water and wondered how the hell it happened. I've become a little gun shy about it, though I do enjoy those games where you're attacking the king side and your opponent's attacking queenside and it's a race to see who breaks through first. Sometimes the board almost looks like a yin-yang Tao symbol.
I've become aware of the weakness of the a-pawn and having to spend a move to bring the king to the b square. But what are some of the general rules of thumb as to deciding whether to castle queen side? What steps should you take for protection?
And when is it appropriate for black to castle queenside? I can't think of any opening variations in which it's routinely done.