In this paper, we develop a mathematical model to investigate HIV infection dynamics, where we focus on the virus’s dual-target mechanism involving both CD T cells and macrophages. Our model is structured as a system of seven nonlinear ordinary differential equations describing the interactions between susceptible, latent, and infected cells, alongside free virus particles. We derive the basic reproduction number, , as two components, and , which quantify the respective contributions of CD T cells and macrophages to viral spread. It is deduced that the infection-free steady state is globally asymptotically stable once , ensuring viral eradication. For , a stable endemic steady state emerges, indicating the persistence of the infection. Later, we develop an optimal control strategy to study the impact of reverse transcriptase and protease inhibitors. This analysis identifies a critical drug efficacy threshold, , necessary for viral eradication. The numerical simulations and the sensitivity analysis provide key parameters that drive viral dynamics, offering practical insights for designing targeted therapies, particularly during the early stages of infection.