The original pharmacokinetics (PK) two-compartment model illustrates the change law of the drug in the central and peripheral chambers after administration, respectively. Although this deterministic model has derived many practical conclusions, it is based on simplifications and neglects noise, which is inherent to pharmacological processes. The actual pharmacological processes are always influenced by factors that cannot be entirely understood or modeled explicitly.Modeling without considering these phenomena may impact the accuracy and the related conclusions. A stochastic type of model can capture such noise. We proposed a novel two-compartment PK model concerning drug administration through intravenous route by combining optimal control theory and stochastic analysis. The selection of the objective function was based on the goal of obtaining the best possible therapeutic effect with the least possible drug dosage.Firstly, we extended the original PK two-compartment model based on optimal control and proved the existence and uniqueness of the switch in the control.Moreover, considering the possible uncertain factors, we added disturbances to the distance between the drug concentration and equilibrium point of the dynamic system and extended the model to a stochastic differential equation model. Qualitative and quantitative analyses showed that optimal controls were bang-bang, that is, alternating the drug dosages at a full dose with rest-periods in-between. Our analysis provided a schedule for optimal dosage and timing.The solutions of the model provided estimates of the drug concentration at any given time. Finally, we simulated the model using R and showed that the numerical method is stable.