In the repair of injury, some transforming growth factor-betas (TGF-betas) and platelet-derived growth factors (PDGFs) bind to fibroblast receptors as ligands and cause the differentiation of fibroblasts into myofibroblasts. When the injury repair is repeated, the myofibroblasts proliferate excessively, forming fibrotic tissue. We goal to control myofibroblasts proliferation and apoptosis with anti-transforming growth factor-beta (anti-TGF-beta) and anti-platelet-derived growth factor (anti-PDGF) medicines. The novel optimal regulator control problem with two controls (medicines) is proposed to simulate how to the preventing pulmonary fibrosis. Idiopathic pulmonary fibrosis (IPF) consists of restoring a system of cells, protein, and tissue networks with injury and scar. Myofibroblasts proliferation back to its equilibrium position after it has been disturbed by abnormal repair. Thus, the optimal regulator control problem with a parabolic partial differential equation as a constraint, zero flux boundary, and given specific initial conditions, is considered. The myofibroblast diffusion equation stands as a governing dynamic system while the objective function is the summation of myofibroblast, anti-TGF-beta and anti-PDGF medicines for the fixed final time. Here, myofibroblast is a nonlinear state of time while anti-TGF-beta and anti-PDGF are two unknown control functions. In order to solve the corresponding problem a weighted Galerkin method is used. Firstly, we convert the myofibroblast diffusion equation to a system of ordinary differential equations using the Lagrangian interpolation polynomials defined at Gauss-Lobatto integration points. Secondly, by the calculus of variations, the optimal control problem is solved successfully using canonical Hamiltonian and extended Riccati equations. Numerical results are given, and the plots are depicted. Moreover, solutions to the problem in which there is no control are compared. Numerical results show that, over time, the myofibroblast increases and then remains constant when there is no control. In contrast, the current solution decreases and vanishes after 300 days by prescribing controller medicines for anti-TGF-beta and anti-PDGF. The optimal strategy proposed in this paper helps practitioners to reduce myofibroblasts by controlling both anti-TGF-beta and anti-PDGF medicines.