A visit to the Doctor is a good idea, perhaps ask him if he gets bathroom breaks at school, sometimes children do not like to ask to go in front of their friends, ask the teacher to quietly remind him to go, this happens a lot ,children want to go and dont want to ask.Make sure he isnt upset by anything, no punishmenst for this it will cause more anxiety, find out why he is doing it ..Good luck