Hello. Welcome to hcm.
Children usually put foreign bodies in their ears and that might get infected leading to foul smelling discharge. Other reason might be a middle ear infection
I advice you to consult a ENT surgeon instead of pediatrician
who will examine ears and treat you accordingly. Foreign body can be removed in opd and if infection in middle,x ray
has to be taken and he should be put on antibiotics for 7-10days after sending the pus for culture.
All the best