In recent years, the medium-depth ground source heat pump (MD-GSHP) has become a promising and potential geothermal energy heating technology. This is due to the superior characteristics of buried pipes with a small diameter, the high energy efficiency of the heat pump, the insensitivity to the ground climate, and other conditions. Among currently available studies, both the variable operating conditions and the addition of thermal storage devices have rarely been considered. Despite this, the optimization methods applied to the medium-depth GSHP system are relatively simple. In this paper, an MD-GSHP system, including the thermal storage device with variable operating conditions, was fabricated. The operation strategies of the system were optimized by employing the improved particle swarm algorithm after applying the operating costs, the coefficient of performance of the system (COP) and the geothermal energy utilization coefficient to the objective functions, and the optimization results were compared and analyzed. The results show that the predictions of the optimized operating costs, the COP of the system, and the geothermal energy utilization coefficient were found to be CNY 279.27, 6.4420, and 0.8527, respectively. The effect of the COP on the optimization effect was opposite to that of operating costs, but analogous to that of the geothermal energy utilization coefficient.