Hi M.,
I am a mother of four boys and I have to tell you that when the boys were first potty trained, they too still had several accidents. My boys are all now potty trained but I have to admit that when my 5 year old is really into something, he does the same thing. I have talked to him about this and have let him know that he is now 5 and that he has to take the time to stop what he's doing GO TO THE POTTY!! How long ago did you get your son potty trained? If he was just potty trained a few months ago, then I can tell you that he still needs to be taken to the washroom regularly; I did mine every 20-30 minutes. Poop for a boy usually takes a little longer than pee during the training stage.
I can tell you not to punish him for it; it will be a negative experience for him. My ex did that with my oldest when he made mistakes with poop and my son to this day tries to hold it back; he is now 11 and it's psychological for him.
They say boys are harder to train than girls; I don't have girls but I have a lot of neices and my sister and sisers in law all share that yes they have had a harder time training the boys than the girls.
Hang in there and just set a schedule for yourself and your child to go to the bathroom every 20-30 minutes. I had mine sit for about 5-10 minutes and even took a book in the bathroom or would strike up a conversation of things they were interested in. Another thing you can do is have his friends that are potty trained and tell him what a big boy he is for using the toilet all by himself and also tell him about the great underwear he gets to wear that a baby wouldn't be able to wear. I've used pull ups or diapers for the car and for sleeping. Tell him his characters don't like to get soiled; it makes them feel bad; it worked for my boys.
Accidents will happen but PLEASE be more understanding than anything because if you get mad or punish him, it can have a negative effect on your child; my son is proof of that and he doesn't soil but he doesn't want to use the bathroom for #2 because of his father and that is something I don't wish on any child.
Good luck to you and your son.