The effective quality factor of the cantilever plays a fundamental role in dynamic mode atomic force microscopy. Here we present a technique to modify the quality factor of an atomic force microscopy cantilever within a Fabry–Perot optical interferometer. The experimental setup uses two separate laser sources to detect and excite the oscillation of the cantilever. While the intensity modulation of the excitation laser drives the oscillation of the cantilever, the average intensity can be used to modify the quality factor via optomechanical force without changing the fiber-cantilever cavity length. The technique enables users to optimize the quality factor for different types of measurements without influencing the deflection measurement sensitivity. An unexpected frequency shift was observed and modelled as temperature dependence of the cantilever’s Young’s modulus, which was validated using finite element simulation. The model was used to compensate for the thermal frequency shift. The simulation provided relations between optical power, temperature, and frequency shift.