It depends on his age and the situation. I don't see cursing as a bad thing altogether. Sometimes it is a very easy way to relieve agressiveness, especially if cursing is not aimed at anybody, but as a cry of frustration.
And as others had already said, there is nothing better than a good example and explaining to him that there are things not acceptable in society.