Yes, my mom did the old soap in the mouth bit. I can still taste Ivory today too! lol I have also been known to do it to my 9 year old in the past, not for potty words, but for lying.
Just get a plain jane bar of soap (Ivory works well, as so many now days have those little beads in them and I think that would be too mean, lol). Talk to them and tell them from now on the punishment for saying those words ANYWHERE will result in getting their mouths washed out with soap. STICK TO IT! Don't threaten it and not follow thru! Get the soap wet and I did one rub on the tongue for each year old they were (so 5 years, got 5 rubs with the bar). It only took a few times for my daughter's habits to stop. Sadly when I was younger it took me a few too many, lol.
Good luck!