Stimulation of hydrocarbon wells with matrix acidizing operation is among the most common operations to stimulate the formation in order to remove the skin and improve the productivity index. But corrosion of equipment, including casings, is one of the most important concerns. In the present paper, the influence of the magnetic field on the corrosion behavior of drilling casing in 1.5 M (5 wt.%) HCl was investigated at various conditions using potentiodynamic polarization (PDP) and weight loss (WL) measurements. Taguchi’s design of experiment (L-18 array) should be utilized to model the impacts of magnetic field intensity, elapsed time, magnetization time, and temperature on the change in corrosion rate. The results of experiments show that passing of acid through a magnetic field reduces the corrosion rate of N-80 carbon steel in HCl up to 96%. Consequently, magnetized acid has a high ability to reduce the effects of corrosion on matrix acidizing operations as a green corrosion inhibitor.