Idioms are usually used in less formal conversation. It is best to avoid them in formal writing. It is also advisable not to use them too frequently. Some idioms also are more familiar to people of a certain age, geographic region, or culture. When in doubt, it is best not to use an idiom. As you hear more native speakers and read more, you will begin to see when it is appropriate to use idioms.