The mathematical model analysis of the dynamics of online gaming addiction with optimal control is the main emphasis of this work. We proved that the dynamical system’s solution is bounded, positive and exists. The linearization method, the Castillo–Chavrz theorem and LaSalle’s invariant principle were used to establish the stability of the system’s two equilibrium points, which are the endemic and online game addiction-free equilibrium points. The basic reproduction number ( \(R_0\) ) of the model was calculated using the principle of the next-generation matrix, and the sensitivity indices of \(R_0\) to the model parameters were investigated. Additionally, bifurcation analysis was performed to verify the backward and forward bifurcations, and from the analysis, we observed that the model system exhibits forward bifurcation at \(R_0 = 1\) . The optimal control problem of the model was analyzed using Pontryagin’s maximum principle, and the characterization of the optimal control was constructed. Numerical simulations were performed to enhance the accuracy of the analytical results. The numerical simulation of sensitivity analysis, decreasing the contact rate with addicted ( \(\beta _1\) ) and incompletely recovered ( \(\beta _2\) ) individuals, the addiction rate ( \(\delta \) ), the relapse rate ( \(\omega \) ) and the incomplete recovery rate of treated individuals ( \(\tau \) ) decreases the reproduction number. Using optimal control, the combined strategy of minimizing the contact rate with addicted individuals and the relapse rate of incompletely recovered individuals minimizes the exposed and addicted individuals as well as the associated cost.