Since the number of patients with chronic hepatitis B virus (HBV) infection is still high globally, appropriate strategies for therapy control are required. In this study, we propose an HBV model consisting of six populations, namely uninfected hepatocytes, infected hepatocytes, HBV DNA-containing-capsids, free viruses, antibodies and cytotoxic T-lymphocytes. The model also includes an adaptive immune response, cure rate of infected hepatocytes, two time delays and two control therapies. The two time delays are delay of virus production after infection by HBV and delay of antigenic stimulation generating cytotoxic T-lymphocytes. The two optimal controls are a therapy for blocking new infection and a therapy for inhibiting viral production. The existence, uniqueness, non-negativity and boundedness of model solutions are first proved. The model is shown to have three equilibrium states, namely infection-free, immune-free and endemic. The basic reproduction number for the stability of the infection-free equilibrium is derived and a sensitivity analysis is carried out to determine the most important parameters to change to control the disease. Then optimal control and the Pontryagin maximum principle are used to maximize the concentrations of uninfected hepatocytes, antibodies and cytotoxic T-lymphocytes at minimum cost.