Field Oriented Control (FOC) effectively realizes independent control of flux linkage and torque, and is widely used in application of Permanent Magnet Synchronous Motor (PMSM). However, it is necessary to detect the phase current information of the motor to realize the current closed-loop control. The phase current detection method based on a sampling resistor will cause a measurement error due to the influence of parasitic parameters of the sampling resistor, which will lead to the decrease in PMSM control performance. This paper reveals the formation mechanism of the current sampling error caused by parasitic inductance and capacitance of the sampling resistor, and further confirms that the above error will lead to the fluctuation of the electromagnetic torque output by simulation. Moreover, we propose an approach for online observation and compensation of the current sampling error based on PI-type observer to suppresses the torque pulsation of PMSM. The phase current sampling error is estimated by the proportional and integral (PI) observer, and the deviation value of current sampling is obtained by low-pass filter (LPF). The above deviation value is further injected into the phase current close-loop for error compensation. The PI observer continues to work to keep the current sampling error close to zero. The simulation platform of Matlab/Simulink (Version: R2021b) is established to verify the effectiveness of online error observation and compensation. Further experiments also prove that the proposed method can effectively improve the torque fluctuation of the PMSM and enhance its control accuracy performance of rotation speed.