My children have done the same thing and it's something that all kids do...they learn it from adults and thier peers.
The best you can do is to be consistent in the discipline. Do not wash thier mouths out with soap because it is a form of child abuse. You can however enforce that those words are not permittable and will not be tolerated.
soap wouldn't work on my kids. i threatenened once so they tasted it to see if or not they would like it. threaten to use pepper. my bet is they'll stop. all kids know pepper is spicy. if that's to child abuse for you (rolling eyes) try the time out method. oh but be sure to let them know what the word is. after my aunt told her kid not to say that word she said "sorry, mommy. i didn't mean i shit a brick. i meant i shit a rock."