It is normal for a horse to cough a few times a day, so if he just did it once or twice it isn't a big deal, especially if it is dusty. When the weather is dry and dusty horses have to produce more tears to lubricate their eyes and keep them clear of dirt, and those tears drain through a duct to their nostrils. So if it has been especially dry that would be expected of your horse. Did the foamy stuff come out of his nose or his mouth? If it was his mouth it was likely just saliva...which is good! It means he is relaxing and giving to the bit. If it was out of his nose I might be more worried. Keep an eye on him and make sure he has plenty of fresh water to compensate for the extra moisture he is using to keep the dust out of his eyes, but other then that it just sounds like a normal reaction to a hot, dry summer.