The overall gain of a scintillation detector is temperature-dependent, leading to a drift in the measured gamma energy spectrum with changes in temperature. To mitigate this effect, a temperature drift correction is essential prior to conducting gamma spectrum analysis. In this study, the detector gain ratio is determined by comparing the positions of the same background peak across different spectra. Subsequently, the original spectrum is adjusted accordingly to obtain a gamma spectrum free from temperature drift. Experimental results demonstrate that after implementing this correction, the relative deviation of the 57Co characteristic peak positions in the gamma spectrum measured by the NaI(Tl) detector is reduced from 18.64% to 0.91%. Furthermore, by performing energy calibration beforehand, the characteristic peak position can be utilized for secondary correction, further minimizing temperature drift. Our findings indicate that the relative deviation of the 22Na characteristic peak positions was reduced, respectively, to 0.51% and 0.46% through secondary correction. This approach, which utilizes the background peak for correction, avoids the need for additional radioactivity or circuitry and effectively mitigates peak drift. Overall, this method holds significant implications for enhancing the accuracy of gamma spectrum analysis.