The viral infection of hepatitis B virus (HBV) is a dangerous problem for health around the globe and counted in the top leading causes of death. To explore the viral dynamics of this infection, an HBV epidemic model has been developed by dividing the infected compartment into three subclasses, acute, chronically infected and carrier individuals with both vertical as well as horizontal transmission. After formulating the model, we prove that the positive solution of the model exists. The next generation matrix approach has been used to investigate the threshold quantity known as basic reproduction number. The global stability conditions at endemic equilibria (EE) and disease-free equilibrium (DFE) are established by using the method of geometrical approach and Castillo-Chavez, respectively. We use the optimization theory and the three time-dependent control variables to establish the control program. By the help of this control policy, we reduce the number of susceptible, acute, chronically hepatitis B infected and carrier persons, while the numbers of recovered and vaccinated populations are maximized. Finally, numerical results will be found out for the support and feasibility of the analytical results.