Castling is not just a move to safeguard your king.It's an important decision that in all cases has to do with the rest of the characteristics of the position.
If I remember correctly Reti said , "We don't castle when we can , we castle when we want".
So your question is impossible to be answered.
One thing you must remember is that chess is not cooking.There are no recipes or magic formulas.That is why understanding is so important.
How to know in which side to castle?That question is ever more difficult for me when i am castling in the middle game.