A delayed model describing the dynamics of HIV (Human Immunodeficiency Virus) with CTL (Cytotoxic T Lymphocytes) immune response is investigated. The model includes four nonlinear differential equations describing the evolution of uninfected, infected, free HIV viruses, and CTL immune response cells. It includes also intracellular delay and two treatments (two controls). While the aim of first treatment consists to block the viral proliferation, the role of the second is to prevent new infections. Firstly, we prove the well-posedness of the problem by establishing some positivity and boundedness results. Next, we give some conditions that insure the local asymptotic stability of the endemic and disease-free equilibria. Finally, an optimal control problem, associated with the intracellular delayed HIV model with CTL immune response, is posed and investigated. The problem is shown to have an unique solution, which is characterized via Pontryagins minimum principle for problems with delays. Numerical simulations are performed, confirming stability of the disease-free and endemic equilibria and illustrating the effectiveness of the two incorporated treatments via optimal control.