Air units can retreat at any time after the first round of combat. They don’t “retreat” to a territory, though. They stay in the territory, removed from the battle. Then in their NCM phase they can use any remaining movement points to get where they want.
If an amphibious assault includes overland units, overland units may retreat at any point after the first round of combat. The overland units may retreat to any territory that any overland units came from. All overland units must retreat simultaneously and to the same territory (ie, no split retreats) that at least one unit came from.
Units which assaulted amphibiously can never retreat once they leave the transport. If there was a sea battle prior to the land battle, and a retreat was needed in the sea battle, the loaded transports could retreat with the retreating naval units. They would then have to remain loaded until the next turn. If an amphibious assault is aborted in this fashion, all overland and air units are still committed to at least one round of battle before they are allowed to retreat.