There isn't a "one size fits all" when it comes to meds. We are all VERY different in this regard.
Depending on your diagnosis, you might only have to be on meds for a short period of time or it could be life-long. That is something up to you and your doctor and your diagnosis.
When I was initially diagnosed about 35 years ago, I saw a psychiatrist who prescribed Desyrel (not sure that one is even around anymore). There was no discussion about how long I was to remain on it. At that time, I also had "talk" therapy with her. She was great and it really helped me. I think I was on the med for a few years, then went off, because I married and we decided to have kids. After a few years, I went back on medication for awhile so that I could learn to "manage" my anxiety. At that point, my docs and myself agreed that I didn't want to be a life-long med taker and that I wanted to learn how to deal with my anxiety on my own. There were ups and downs, but I eventually got off the medication. My anxiety didn't get worse - at least not right away. Over time, I had to go on other meds for "depression" (as far as I was concerned it was anxiety, but doc diagnosed it as depression). Prozac worked great for awhile - was on that for a few years. Life was good. I was busy and didn't have time to even think about my anxiety. I felt so good that I decided to go off my med. This is a pretty common response to people on meds - feeling good and going off. I figured I had been on it long enough and I could deal with everything on my own. I did for awhile, but then along came hormone changes and the anxiety came back big time. Then more hormone changes. But during that time, I only asked my doc for a prescription of Ativan to take under dire circumstances because I did not want to take medication regularly. At this point, I was learning that anxiety (and possibly depression) is attributable to repressed emotions. The more I study up on mindbody science, the more I agree with it. So, I've looked in to neurofeedback and other alternative non-medication forms of treating the anxiety and they work. To me, taking a med for anxiety and depression are just band-aids. It's not getting to the underlying reason of what's really going on.