In order to solve the problems of wind power output volatility and wind power participation in frequency regulation, a method for optimizing the capacity allocation of wind farm storage batteries based on the dual grouping strategy and considering the simultaneous execution of the dual conditions of energy storage in fluctuation smoothing and primary frequency regulation is proposed. Firstly, a two-layer model is established to optimize the capacity allocation under dual operating conditions, i.e., the planning layer takes into account the lifetime, cost, and benefit, and the operation layer considers the wind turbine reserve backup and storage control to participate in the primary frequency regulation in a cooperative manner. Then, the dual battery pack operation strategy is embedded with the variational modal decomposition method to determine the charging and discharging operation strategy of energy storage after considering the grid-optimized reference power. An improved particle swarm algorithm with inverse learning pre-optimization combined with variational crossover post-optimization is embedded in the GUROBI computation to obtain the optimal battery storage capacity allocation scheme. Finally, the superiority of the model proposed in this paper in terms of improving energy storage utilization, service life, and economic efficiency as well as reducing wind power load shedding is verified by comparing it with a single execution working condition scenario and traditional battery control strategy.