My little boy has a ear infection

i am thinking he got it from all the swimming he has been doing. I took him to the vets and got him meds for it but all the infection??? seems to be draining out of it. I have tried to take a damp cotton ball and wipe the outside part of his ear but it still seems to hurt him. How can i clean his ears without hurting him? He is a chi and has the tall pointy ears so i can clearly see into them. I have been trying to clean it before i put the medicine.