When dealing with whole colonies, you can superglue them to the live rock or stick them in holes.
When dealing with frags, if the rock they're on won't fit or isn't stable, you can break them off the rock and re-glue them directly to a nook in your live rock. The glue does not hold well on flat surfaces underwater: you need to set it in a hole. You put a big wad on, count to thirty or so, then stick it into the place it should go and don't move or twitch for another couple of minutes until it 'takes.'