A mathematical simulation model of a beam pumping system with frequency conversion control is established, considering the influence of the real-time frequency variation on the motion law of a pumping unit, the longitudinal vibration of a sucker rod string, the crankshaft torque, and the motor power. On this basis, the key links such as state space, action space, and reward function are defined by using deep reinforcement learning theory, and an intelligent model to optimize the frequency modulation for a beam pumping system based on deep reinforcement learning is constructed. The simulation and field application results show that the frequency optimization model can significantly reduce the fluctuation amplitude of the polished rod load, crankshaft torque, motor power, and input power of the system, making the operation of the pumping system more stable and energy-saving. More importantly, the model can realize the independent learning and control of the corresponding parameters without manual intervention to ensure the normal operation of the system and improve the level of information and intelligent management of oil wells.