Hello and welcome to healthcare magic.
Painful defecation and sore anus may be due to following reasons
Anal fissures:Prolonged
constipation and straining can cut the anal skin leading to anal fissures which is a very painful condition and can exacerbate the situation by creating fear of defecation and retention which lead to leaking stools and soiled pants.To rule out this condition he needs to be examined by paediatric surgeon.I advise
xylocaine gel,sitz baths and
stool softener in such situations.
Pinworms:They irritate th sensitive skin moreover itching can also lead to raw skin.Contact of stools with raw skin will hurt alot specially if the stools are hard.Local examination,Stools inspection and stool routine examination will cofirm the diagnosis.I prescribe
zinc oxide cream and
Albendazole syrup in such situations.
Food allergy:It makes the stool acidic which irritates the skin and similar condition develop as in pinworms only that acidic stools will burn the skin more.
Stool test for reducing sugars can confirm the diagnosis.Zinc oxide cream and omitting the alleged food will be my advice in such situation.
4th Condition which is very sensitive and grave matter both for you and us(ur treating team) that is sexual abuse must be kept in mind.It can lead to sore/inflamed anus and fear of Defecation.AND you MUST be very vigilant to keep an eye and must INTERVENE if such situation is possible.
Hope you find this answer helpful.Good luck!