Usually in conversations(sometimes we use it and not realized that we were using it.) In a piece of writing if you write.
Idioms, in other words, are part of the figurative language.
A lot of authors use this in their works, specifically those written for entertainment.
You can also use idioms when talking to another person, in daily conversations and the like.
Just remember that idioms are not to be taken seriously.