A novel magnetic field sensor comprising a photonic crystal fiber (PCF) is designed and investigated based on surface plasmon resonance (SPR). We use finite element analysis in order to analyze the sensing characteristics of the magnetic field sensor. The simulation results show that the sensor is very sensitive to the change of refractive index and has good linearity in the refractive index range from 1.43–1.45. The thickness of the metal film and the metal material has great influence on the resonance wavelength and the peak of the loss spectrum, the diameter of the central air hole will affect SPP excitation. When the thickness of gold layer is 50 nm, the refractive index sensitivity is 4125 nm/RIU in the refractive index range from 1.43–1.45. Using the designed sensor for magnetic field sensing, the loss spectrum is red-shifted with the increase of the magnetic field, the highest magnetic field sensitivity can reach 61.25 pm/Oe in the range from 50 Oe to 130 Oe. The sensor not only has high sensitivity of refractive index, but it can also realize accurate measurement of magnetic field. It has huge application potential in complex environment, remote sensing, real-time monitoring, and other fields.