Your question stresses how important it is to habituate dogs to be manipulated in different ways. It is important to start with young puppies and continue playing this "game" as they grow up.
By manipulation I mean
- being lifted off the ground
- ears touching
- gentle "eye cleaning" (this should be done very cautiously even if your dog is OK with it)
- touching, moving his paws
That's something that should be done everyday or even multiple times a day, often people realise the importance of it when it is really needed (visit to the vet, injury, etc.).
Habituation has a specific "scientific" meaning: habituation is the decrease of a response to a given stimulus, or equivalently, a response that stays constant while the stimulus is gradually and slowly increased.
So habituation is passive and will develop over time. Concerning your dog's ears, that means that if you touch (first with one finger, then after some days with 2 fingers, etc. and finally holding the ear in your hand) his ears while petting him, if you start with something that doesn't provoque a strong reaction (otherwise it means you went to fast) your dog will habituate and you'll be able to progress over time.
Of course in your case that would be too slow and you need to take active steps.
That other process is counter-conditioning: classical conditioning is the association of a given stimulus to a innate rewarding experience (that's a experience that the dog finds rewarding without being trained: food, social contact, etc.). Your dog considers ears touches as a negative experience. You need to (classical) counter-condition him to eventually associate ears touches with a rewarding experience.
Here are a key points to do that properly:
- actively practice that exercice before your dog associates it with a negative experience too strongly (that means everyone should do it before it is really needed)
- start with something your dog is confortable with, don't rush it: in your case that might mean that you have to start by just petting his head
- reward him in the following way: first give him a treat as you're touching him, then treat him after touching, when is confortable being touched in a given way and expects the treat move slowly to harder steps, again treating as you're touching his hears then treating after
The last point is the most essential ingredient of classical conditioning: the stimulus (touching his ears) has to become the predictor of the reward. That means it has to be given first and the reward has to come after.
Treating as you touch serves to habituate the dog, then treating after serves to condition the dog that having his ears touched is a wonderful experience.
I have to admit that although it sounds great on paper, it is a slow process, especially if the dog already had a chance to learn non-rewarding / negative experiences.
In the short-term your best option is to try to make it has positive as possible: immobilise him "strongly", so you can be faster, treat him before and after, or during if you can have someone else's help. Vets are usually doing such things with a lot of confidence, calm and rapidity.