I wouldn't punish him at home as well, as the crime was committed in the school and the time carried out there.
I'm not sure what you should say. I have the same problem with DS, he is only in reception and the school have a reputation for cursing amongst the students. I always thought the way was to ignore it, and then they'd stop, as it is the reaction they're after if you make a big deal out of. But I'm probably wrong.
He used to say to me, that's a bad word, this is a bad word, which I don't like either, words are words, neither bad nor good. Have also had the inappropriate words chat with him. Something I just remembered is they used to call them "pass"words, ie, not to be said, so pass over them. I will start using that again I think.
If you get any tips on how to stop it, let me know! (DH and I also swearers, mostly when hurting, or something breaking, or an idiot of a driver! and have been working on it too)
Both you and your lad can get on this. He can tell you off when you swear, which means that you'll realise you're doing it more and he'll be less inclined to do it as he knows that it's properly naughty if Mummy is being told off too. I'd explain to the teacher exactly what you're doing.