It's never SAFE unless you have the nut hand at the river or the like. Most of the time that you'll have to go all-in you won't be safe... although if you have more chips than the all-in player, then you're not in danger of going out immediately.
If you want safe options, then poker isn't for you - you take calculated risks as a matter of course.
When you'd go all-in during play depends on your chip stack relative to the blinds, and what kind of hand you have, and also what kind of opponents you have at the table. Sometimes pushing all-in is an effective way to buy the blinds, and get yourself a few more chips, and is done based on a good position and hopefully a good read on your opponents. Sometimes it's when you're short-stacked, and can't wait any longer for a good hand, and just have to take the chance that you're behind and hope to get lucky. Sometimes you're really short-stacked, and the big-stack has just pushed all-in, so you push in to try to get the opportunity to only be against one opponent with all your chips on the line. Sometimes you'll push in on a bluff. There are many situations where you may need to go all-in, and it's not something that can be answered in a short post.
If you have less than 10x the big blind, consider pushing all in when you like a hand you're dealt. If you're seriously short-stacked, consider pushing in with whatever cards if a big stack pushes all-in. Other times it's trickier to know whether to push or just raise...