Some children do not like to ask teachers if they can use the bathroom, this is a very common problem,teachers dont remind the children especially as they get older, it may be wise to speak to the teacher and ask her to discreetly remind your son.Punishments do not work they make the issue worse by creating anxiety.
School can be a very over stiimulatiin environment, in other words overwhelming! Yelling and punishment is NOT going to help. I would figure out when its happening, recess, class? Is he embarrassed to ask to leave class. Or scared to go to the bathroom Alone? is he being bullied? Or is it during Recess and so busy playing he forgets. This is comon, I have an 8,10 & 12 year old. I also teach preschool. Send extra clothes and remind him to go to the Bathroom between lunch and recess. Talking calmly and problem solving with your child with out making a big deal out of it is your best bet. It's embarrassing enough To have an accident at school Without having your parents freak out on you. Support him rather than be against him.