This study involves the mathematical modeling of long-term HIV dynamics and the investigation of optimal treatment strategies. The model duplicates literature-reported clinical data with good agreement and is able to predict the entire trajectory of the disease. The model is extended to account for therapy and the emergence of drug-resistant virus and used to investigate how continuous therapy and Structured Treatment Interruptions (STIs) can be implemented in an optimal manner to extend the life-expectancy of an HIV-infected patient to desirable times, while at the same time minimizing drug-related side-effects. Whereas the former fails when treating patients that have developed strong drug resistance, STIs prove to be very promising. This is because the optimal schedule of ON and OFF treatment allows for the interplay between the drug-sensitive and drug-resistant virus and prevents them from growing in an uncontrolled manner. As a result, uninfected CD4+ T-cells are maintained at relatively high values at all times.