I really don't think you should worry too much, its possibly a phase he's going through. I had the same with my little one when he turned 4. He'd come back home everyday from school with wet pants. He was just so busy playing he'd forget to go to the toilet in time! He's now 5 and we haven't had a single problem for months! I think this mostly happens to active little ones who just don't wonna stop playing in order to take the much needed pee! :-)
Don't punish him as this will only add anxiety. and the child will know its an issue.
I dont think punishments are going to help, the best way is to find out why, what has happened in the three weeks, has he started at a new school, /daycare have you moved, new sibling ,,new family members. anything that could upset him, does he get on well at school with friends /teacher,some times children do have relapses, dont make a big deal of it as it will cause anxiety.If he is at school/daycare make sure he gets enough potty breaks ask the teacher if they remind the younger children to go..