Clarifying the distribution of temperature and pressure in the wellbore and cavern during hydrogen injection and extraction is crucial for quantitatively assessing cavern stability and wellbore integrity. This paper establishes an integrated flow and heat transfer model for the cavern and wellbore during hydrogen injection and withdrawal, analyzing the variations in temperature and pressure in both the wellbore and the cavern. The temperature and pressure parameters of hydrogen and natural gas within the chamber and wellbore were compared. The specific conclusions are as follows. (1) Under identical injection and withdrawal conditions, the temperature of hydrogen in the chamber was 10 °C higher than that of natural gas, and 16 °C higher in the wellbore. The pressure of hydrogen in the chamber was 2.9 MPa greater than that of natural gas, and 2.6 MPa higher in the wellbore. (2) A comparative analysis was conducted on the impact of surrounding rock’s horizontal and numerical distance on temperature during hydrogen and natural gas injection processes. As the distance from the cavity increases, from 5 to 15 m, the temperature fluctuation in the surrounding rock diminishes progressively, with the temperature effect in the hydrogen storage chamber extending to at least 10 m. (3) The influence of rock thermal conductivity parameters on temperature during the processes of hydrogen injection and natural gas extraction is also compared. The better the thermal conductivity, the deeper the thermal effects penetrate the rock layers, with the specific heat capacity having the most significant impact.