The large-scale integration of offshore wind power into the power grid has brought serious challenges to the power system power quality. Aiming at the problem of power quality disturbance detection and classification, this paper proposes a novel algorithm based on fast S-transform and crested porcupine optimizer (CPO) optimized CNN. Firstly, the intrinsic mechanism and waveform characteristics of offshore wind power grid-connected disturbances are analyzed, and the simulated disturbance signals are feature extracted and time-frequency diagrams are obtained by fast S-transform. Secondly, the CPO algorithm is used to optimize the convolutional neural network and determine the best hyperparameters so that the classifier achieves the optimal classification performance. Then, the CPO-CNN classification model is used for feature extraction and feature selection of the time-frequency diagrams and classification of multiple power quality disturbances. Finally, a simulation experimental platform is established based on MATLAB to perform simulation verification and comparative analysis of power quality disturbance classification. The experimental results show that the model established in this paper is effective, and the classification accuracy is improved by 3.47% compared with the CNN method, which can accurately identify the power quality disturbance signals, and then help to assess and control the power quality problems.