Because the manufacturers are also aware of the possible contamination of in-ear headphones, replacement tips are included and also offered individually. However, if you don't want to buy these replacements regularly, you can simply clean the in-ears yourself with a little care.
To do this, remove the attachments, i.e. the e.g. rubber or silicone cushions, which are most likely to become soiled by e.g. earwax. These can then be cleaned well with soap and water, stubborn dirt can be removed well with cotton swabs or toothpicks.
If some dirt should have slipped on the grille or even through the grille, try to remove this dirt by blowing. Otherwise, light compressed air or a cold hair dryer on the lowest setting can help. If that doesn't help either, stick on an adhesive strip and try to remove the adhering dirt together with the adhesive strip again. If everything is clean and the attachments, in particular, have dried after wet cleaning, you can put them back on the earpieces.
So cleaning in-ear headphones is nowhere near as complicated as it seems. By the way, to directly prevent contamination, you can carefully wipe the headphones with a clean cloth after each wear and directly remove visible dirt.