It is crucial in a wide range of applications based on optical fiber interferometry to precisely measure the length difference. In this article, a method of measuring the optical path difference between two arms of an optical fiber interferometer system based on the phase modulation of light source is proposed. This method enables measurement with the resolution of centimeter level and is suitable for both meter-scale and kilometer-scale optical fiber interference systems, which has a broad prospect in engineering applications. We present a low-cost and easily implementable method for measuring and compensating the length difference of an in-service optical fiber interferometer.