Ignore it. If your child is using words that make you cringe (or let's face it, laugh), try not to outwardly react. Certainly you can and should correct your child, but try to have as little as a reaction as possible. Why? Because your reaction (negative or positive) is still a reaction. And there's nothing a little kid likes more than to get a strong response from a grown up.
Punishment. Sometimes a swift reaction is all you need to get your message across. If you child says a bad word or uses language you aren't crazy about, react immediately. Say something like, "We do not use words like that in this house," and then put him in a time out. When the time out is finished, ask your child why he was punished, so you are reinforcing the lesson and then have him say that he is sorry. Explain that if he uses language like that again he will return to time out.
Watch your own language. Children truly do learn what they live, so if you are using foul language on a regular basis, chances are she's picking it up from you! If that's not the case, try to figure out where your child did learn the naughty words, such as at school or at daycare or even a friend's house. If you have concerns, address them directly with the adult in charge, explaining that lately your child has been speaking some not-so-great words and you are wondering where she got them from. It's possible there is a child in the class or an older sibling who has been serving as a "teacher."
Be direct. If your child regularly speaks words you aren't happy hearing, it's time to have a talk. Tell your child you don't like those types of words, that most people don't like those types of words and that she needs to stop saying them. If it helps, pick a favorite preschool character like Lightning McQueen or Dora the Explorer. Ask her if she thinks that character ever says naughty words.
Offer up a substitute. If your son is constantly using the word "poopies" in conversation (and not in a potty training sense), you need to teach him an alternative -- "pickles" or "pineapples" for example. If your child is mad, using expressive language is a way for him to express himself, so the key is to take the naughty word and swap it out for a funny one, but giving your child the opportunity to still make his feelings known. When Even "I'm mad!" can go a long way to helping your child let off some steam.