J.P.
One of my sons had the same issue with poo in his underwear until he was 10 or 11. He was VERY embarrassed about it as much as I was frustrated and confused. He was a very intelligent person but this was very annoying! The problem was that he thought he was only going to be 'passing gas' and by the time he discovered it was the REAL DEAL, it was too late to make it to the restroom (even when he was at home). He was able to keep the bulk of it from coming out, but only after that 1 little droppling had passed through. Somehow he managed to keep the rest from coming out until he could get to a restroom. I told him he needed to go to the bathroom whenever he felt that 'feeling' no matter WHAT... He eventually outgrew the problem.