This is a very commonly asked question, but one that is difficult to answer precisely. Therapy can last for just a few sessions (solution- focused ) or for many years (psychoanalysis). It depends on the type of therapy, the nature of your problem as well as your goals for therapy.
Ultimately, you have the choice and can decide how long you wish to work with a therapist. You may prefer a long-term, broader and more in depth approach; whereas others look to having fewer sessions to work on a specific issue. This can be followed up if and when it is needed.