To analyze the additional cost caused by the performance attenuation of a proton exchange membrane electrolyzer (PEMEL) under the fluctuating input of renewable energy, this study proposes an optimization method for power scheduling in hydrogen production systems under the scenario of photovoltaic (PV) electrolysis of water. First, voltage and performance attenuation models of the PEMEL are proposed, and the degradation cost of the electrolyzer under a fluctuating input is considered. Then, the calculation of the investment and operating costs of the hydrogen production system for a typical day is based on the life cycle cost. Finally, a layered power scheduling optimization method is proposed to reasonably distribute the power of the electrolyzer and energy storage system in a hydrogen production system. In the up-layer optimization, the PV power absorbed by the hydrogen production system was optimized using MALTAB+Gurobi. In low-layer optimization, the power allocation between the PEMEL and battery energy storage system (BESS) is optimized using a non-dominated sorting genetic algorithm (NSGA-II) combined with the firefly algorithm (FA). A better optimization result, characterized by lower degradation and total costs, was obtained using the method proposed in this study. The improved algorithm can search for a better population and obtain optimization results in fewer iterations. As a calculation example, data from a PV power station in northwest China were used for optimization, and the effectiveness and rationality of the proposed optimization method were verified.