The best treatment for the fear of heights, also called acrophobia, is cognitive behavioral therapy (CBT). CBT helps to identify your irrational thoughts about being in high places, which often lead to anxiety. Also, CBT helps to address your avoidant behaviors, which only serve to maintain your anxiety.
During CBT, an important part of treatment is gradual exposure to your fear of heights. This is called exposure therapy. In exposure therapy, you are presented with less threatening forms of the fear of heights, such as just talking about being on top of a tall bridge or building. This will induce some anxiety, and once your are able to utilize relaxation techniques to calm down, your anxiety subsides, and you are able to handle the next exposure. As you handle each exposure, you are given more challenging exposures, such as seeing a picture of being on top of a tall bridge or building. Eventually, you are able to go onto the tall bridge or building in person, and utilize relaxation techniques to help you reduce your anxiety. Eventually, you are able to go on top of tall bridges and buildings without much anxiety, as you have done the exposure work and no longer avoiding.
The following video details how the fear of heights develops, and what you can do to treat it: