Cathodic protection is an important method to inhibit the electrochemical corrosion of pipelines, and its potential distribution directly affects the pipeline protection effect. Taking a product oil transportation station in Northwest China as an example, the distribution rule of the cathodic protection potential of the pipeline was studied using COMSOL Multiphysics simulation software, and the main factors affecting the distribution of the cathodic protection potential of the pipeline were analyzed and determined to be the embedding position and output current value of the auxiliary anode. The optimal protection potential of L360 pipeline steel in the simulated soil solution of the product oil transportation station was obtained through electrochemical experiment analysis. Then, the objective function was established with the anode number, anode laying position and anode output current value as optimization goals. The optimal anode quantity, the optimal anode position, and the optimal anode output current value were searched and obtained by the simulated annealing algorithm. Finally, the feasibility of the optimization scheme was verified based on the actual protection potential of the pipeline, which proved that this method could provide a certain reference for the design of cathodic protection.