You didn't give any background as to where the boy stays the majority of the time or if he is shuffled back and forth between mom and dad, but it could be emotional problems as some kids wet and /orpoop themselves when those kinds of issues arise, also, when is it happening? At night? Day time? He may have a physical problem that needs to be addressed if he is unable to stop himself and is unaware(especially at this age) that it is about to happen. So a pediatrician may need to be involved if it's something physically wrong. Good Luck!
Many times it is about anxiety and not feeling welcome and like they belong. If that's in "check" then ask the mom if he does it at home. If it is only done with you guys then work on establishing trust.
Be careful not to shame him about it. Just deal with it matter of factly and move on. Explain why it is not ok to poop the pants and what is acceptable.