If you have children younger than mine that may not understand the nuance of context and appropriateness, you may want to try the method I employed when my daughters were 3 and 5:
My oldest decided to try out one of my colorful swear words while we were driving to the grocery store. While I was taken aback — even though my husband warned me plenty that if I don’t clean up my own potty mouth, the girls would inevitably follow suit — I didn’t bat an eyelash, but instead starting singing the word over and over again and combining it with other words that rhymed with it. Soon thereafter, the conversation smoothly moved on to the Littlest Pet Shop. This accomplished two things:
1. They were not sure what the bad word was anymore;
2. All the fun was gone. Kids love to test the world and when something they do gets a big emotional response from grown-ups, they are sure to try it again.
So, yes my advice is unconventional, but it works for my family. I still get to swear like a banshee when needed (i.e. car battery is dead, hammer gets dropped on my barefoot toe, kids are driving me crazy) and my children look at me with mild disgust and say pay-up mom or we will wash your mouth out with soap!