If you know that you're allergic to bee venom then you would carry an EpiPen or equivalent epinephrine (adrenaline) delivery system.
Otherwise prevention through observation is the best strategy. When you do your pre-climb tree assessment look for paper nests (bald-faced hornet) attached to branches. They often build their nests in clumps of fine branches and leaves. For honey bees or other cavity dwelling stinging insects look for regular activity: bees flying in and out of a cavity or hole. A hive can be too high in a large tree to be observable from the ground. When you're climbing always be aware of bee and wasp/hornet activity. If you see them before you're on top of a nest then you can back off safely.
European or domestic honey bees (Apis mellifera) are non-aggressive but a hive in a tree should be avoided. Africanized honey bees are physically similar to their docile cousins and are well known to be extremely aggressive. Clearly you don't want to be climbing in a tree with an active hive of any species of honey bee since you can only determine the difference by their behavior, by then it's too late
Individual or foraging bees away from the nest are not a hazard. Even if they are buzzing around your head they are only investigating and not attacking. Swatting at them can provoke them to sting.
Here's a good page for bee safety and first aid:
Bee safety
I don't believe there are any aerosol insecticides that would protect you from bees defending a nest. You wouldn't want to do a pre-emptive attack unless there was some other reason that a nest or hive had to be destroyed (tree removal or a proximity hazard to your house or family for instance).
-moss