In this study, a very crucial stage of HIV extinction and invisibility stages are considered and a modified mathematical model is developed to describe the dynamics of infection. Moreover, the basic reproduction number
R
0
is computed using the next-generation matrix method whereas the stability of disease-free equilibrium is investigated using the eigenvalue matrix stability theory. Furthermore, if
R
0
≤
1
, the disease-free equilibrium is stable both locally and globally whereas if
R
0
>
1
, based on the forward bifurcation behavior, the endemic equilibrium is locally and globally asymptotically stable. Particularly, at the critical point
R
0
=
1
, the model exhibits forward bifurcation behavior. On the other hand, the optimal control problem is constructed and Pontryagin’s maximum principle is applied to form an optimality system. Further, forward fourth-order Runge–Kutta’s method is applied to obtain the solution of state variables whereas Runge–Kutta’s fourth-order backward sweep method is applied to obtain solution of adjoint variables. Finally, three control strategies are considered and a cost-effective analysis is performed to identify the better strategies for HIV transmission and progression. In advance, prevention control measure is identified to be the better strategy over treatment control if applied earlier and effectively. Additionally, MATLAB simulations were performed to describe the population’s dynamic behavior.