A horse can be gelded as soon as he is fully dropped. This could be as early as a week or as late as a year or two. If a horse isn't dropped by his second year, he is known as a cryporchid and the surgery is more difficult. (but still should be done.)
It is my understanding that the sooner you geld your horse, the more height potential he has. (subject to genetics) the later you geld your horse, the more "muscular" they can be, due to testosterone, but they will/may be shorter in height due to the growth going to the muscles.