Thanks for your query.
Your child is having balanitis
which could be due to fungal or bacterial infection.
I suggest to to get him examined by doctor as he may require a course of antibiotics.
In the mean time for pain relief give acetaminophen
in prescribed dosage.
Head of the penis and foreskin should be washed and dried.Wash it thoroughly and gently with warm water ,do not use soap.
Wishing your child good health.