Last year, my son met a boy similar to the one your child met. The boy even taught my son some more colorful language than what your son was appraised of, incl. 'boobies' and 'wiener' and "the F word" (no, not fart, although that one was bandied about).
I wrote a whole post on my blog (The Mother of All Words) earlier this year, but long story short, I conveyed expectations to my son, and kept consistent with my directions and consequences.
One thing I did have a very stern conversation with my son about was that he was especially not to use that sort of language--even the silly 'poop' stuff, in class at school. That this was out of respect for the teacher and the class rule of 'helping the teacher teach/helping the other learners learn'. If he was silly and used those words during instruction/class time, if kids were laughing at him, would they be able to focus on the teacher? How would the teacher feel about that sort of language in her classroom while she was trying to teach? And, if I *ever* heard of him using that sort of language (the swearing, not the general scatological talk) at school "your teacher will having a discussion with me, and daddy and I will be having a discussion with you. And you will be losing privileges."
I stuck to it. When he dropped the F bomb at home a couple days later, the world kinda stopped. He spent the entire afternoon until dinner in his room, the legos were removed for the entire evening (which was huge for him-- pick your son's 'favorite thing in the whole world' to remove as a consequence) and he lost his 'stay up' time he gets on the weekend.
The next day my son told me that it 'wasn't worth it' to use bad words.
So, that's how we nipped it in the bud. We've had a couple nights at dinnertime where we gave him one "go talk like that in the bathroom please" warning and then just removed his plate-- he was done with dinner because of poor manners and no, no food later on. Bummer.
In any case, that's what I would do in your situation: state the expectation, let him understand the consequence for any disruptive behavior on his part, and go from there. Kids are going to do/say those things at recess or in the bathroom at school, too. It just happens. So really, focus on 'letting the teacher teach' and let him know that 'if I hear from the teacher that you are using those words in class, X (consequence) will happen." Make it something that gets his attention. I ignored swearing when my son was little and couldn't understand the logic of good/bad words--just rephrased/redirected him, however, once he got older, he was held accountable for his language.