There are some ground rules to be established right in the beginning. Never call your horse when you are going to do something unpleasant to him like deworming. If the horse senses that it is not going to be good when he comes to you, he is never going to do so voluntarily. So during training him, avoid this. If you still have to do such stuff like giving him shots, walk up to him yourself and do it instead of calling him and ruining the whole training effect.
Decide on a sound to call him. This could be a name or even a whistle. Stand at a distance from him, call him with the decided sound. Walk to him and give him a carrot. This process is done to feed it into the horse's mind that your call means something positive or a reward in the form of a carrot.
Do this a couple of times until your horse is used to hearing the sound and getting a carrot. After the association is strong, you can call him from a distance and let him come to you himself. When he does, reward him with a handful of carrots as a bonus. Stroke his neck and tell him that he is a good boy.
After the horse is well trained, he will come to you whenever you make the sound. However, make sure that he can hear you from the distance between you and him. For a horse owner, there can be no better feeling than knowing that your horse will be there in moments of a single call.