Tell him on the way to the doctor that he may have to get an injection and that the injection is to keep him healthy. If he asks you if it will hurt, then tell him the truth - say it will hurt for a few seconds and then it is over. This way, he will know what to expect. Leave the final decision of the injection to the doctor.
Studies have also shown that children do a lot better if the parents have a nonchalant attitude to injections - in other words, do not sympathise too much, yet do not be cold hearted about it either.