Is he scratching it a lot?
If so, I'd assume mites, and treat him with ivermectin. See
https://www.guineapigcages.com/forum/threads/111160-How-to-treat-for-mites-and-lice.
If not it may be a fungus or a bacterial infection. When you're not sure which (and that's most of the time!), you start with antifungal medicine, such as Nystatin or Lotrimin. They're available at any pharmacy. Apply twice a day with a q-tip, and rub it in well. If it starts to look better, keep treating it for several days after you think it's well, as fungal infections can take a while to clear up.
If it doesn't improve, or gets worse, then switch to a triple antibiotic cream, also available at any pharmacy.
We start with an antifungal cream, because if we're wrong and lesion is bacterial, the antifungal cream won't make it any worse. That's not always the case when you apply an antibiotic to a fungal lesion.
I don't think the fact that he closes his eyes when you touch his ear means that he's in pain. If you were hurting him, he'd flinch, or squeak, or try to get away from you.