Temperature changes in CO2 foam-fracturing construction can easily affect surfactant foam stability. To investigate the effect of temperature on the foam stability of different types of surfactants, this study measured the foam half-life and viscosity of four typical surfactants, CTAB, LAS-30, HSB1214, and TX-10, using a novel self-designed and built foam performance measurement device. The effects of temperature on foam half-life and viscosity were studied. The results show that as the temperature increased, the half-life shortened, and the viscosity of the liquid phase decreased, which led to a decrease in foam stability. Moreover, using Materials Studio, a type of molecular simulation software, an interfacial model of the foam film was constructed to calculate the IFE and the self-diffusion coefficient of water molecules at 300 ps after the equilibrium of the foam system to investigate the mechanism of temperature influence on the stability of the foam. The results show that, for CTAB, LAS-30, HSB1214, and TX-10, the temperature increases from 15 °C to 45 °C, the IFE is enhanced by −50.05%, −59.10%, −64.21%, and −44.26%, respectively, the interfacial system changes from a low-energy state to a high-energy state, and the interfacial stability decreases. Meanwhile, Dwater increased 1.10-fold, 0.78-fold, 1.43-fold, and 0.64-fold, respectively, which accelerated the diffusion and migration of water molecules, weakened the intermolecular forces, and accelerated the instability of the foam system.