I had teachers like that who would frequently make unnecessary offensive comments about other students (and sometimes other teachers). It wasn't funny. I used to be a bit sensitive as a child and had to learn to develop a thick skin. But I have to say I'm glad I learned that during my school years and didn't have to face upsetting comments for the first time in a professional setting.
It must be so irritating and I'm not sure talking to the teacher about it would bring anything. I hope you can help your son get over this incident. There will always be teachers who don't care much about doing a good job. Unfortunately I don;t think you can protect your son from all future harsh comments and unfair behaviors by teachers or fellow classmates. Maybe you can tell him how proud you are of him and how much you believe in him. Explain that it doesn't matter what others say. Strengthening his confidence might make it easier for him to not get bothered by future comments by his insensitive teacher.