Instead of punishing your child for mimickry (something that 2 1/2 year olds naturally do) punish the person or person's who introduced your child to the words because they should know better, but he cannot. I hate to sound like your mother but your child is a sponge. Turn off the TV or if you have to watch shows that use those words, or watch it when your child is asleep. But please, don't punish your kid for repeating words that you allow him to hear. He is after all still learning to talk. It is your job to show what type of behavior is acceptable. If someone says those words in your child's presence let them know that they can't do it again.
i love this response! i remember when i was kid hearing my mom tell my dad (who seriously favors the f-word) that she was going to slap him if one of us kids started repeating his foul language. my older brother was always trying to convince my younger sister to say the word just to see if my mom would slap my dad but i don't any of us ever cursed at our parents... at least not until we were teenagers
for my kids, my husband and my siblings know that swear words are not aloud in my house. whenever my husband spends a day with his brother or cousin, he comes home with a case of potty mouth and i have to give him "the look" a few times but for the most part there is no cursing in our house. thanks to that and keeping close tabs on what our kids watch on tv, neither my 2 1/2 yr old daughter nor my 10 yr old son have ever said a single swear word in our presence.