My daughter had the same problem when toilet training. She would actually go sit in the closet and poop in her underwear but go on the toilet without an issue. She was about 5 when it finally stopped.
It seems reasonable to schedule toileting visits given his recent accidents. I could not tell from your post whether your son is having urine or BM accidents, or both. In addition, to help your son with reaching full continence during the day and night I would suggest (1) a system of rewards for dry/clean pants (consider saving a bigger reward for BMs), (2) restricting fluids in the hour or 2 before bedtime, (3) a toileting visit immediately before bed. Try not to discuss diapers in a negative way as he may need these until his toileting improves. Instead, you might try to encourage him by purchasing his favorite underwear or special pajamas when he has been dry.