You are correct that only an infected mosquito can transfer the heartworms (microfiliaria) to a dog through biting it. It is case by case if a dog should not fly~~and it's a question for the vet at the time he examines the dog for the health certificate. Generally, unless the HW is advanced & the dog has heart or lung issues it is safe to fly them in small planes like PNP pilots use. It is not the case with commercial flights where they are in cargo though because of the air pressure at the heights those planes travel. (This is what my vet told me when I consulted him).
It is up to the individual pilot & your vet, but HW+ dogs have been flown. I hope this addresses your concerns satisfactorily.
You can also read 2 other opinions when I asked the same question a year ago. viewtopic.php?f=3&t=6225&p=26912&hilit=heartworm#p26912