Deep and ultra-deep oil and gas reservoirs are characterized by extreme temperature and pressure conditions. During drilling, bottomhole temperatures often exceed the tolerance of downhole tools, leading to signal loss and damage to key components. Accurate prediction of the wellbore temperature field is therefore critical for ultra-deep drilling operations. Cementing quality significantly affects heat transfer between the wellbore and the formation, yet its influence is often neglected in existing prediction models. This study incorporates cementing quality into wellbore–formation heat transfer analysis, develops a method to calculate the effective thermal conductivity of cement, and establishes a transient heat transfer model based on energy conservation. The model is discretized and solved using the finite difference method. The effectiveness of the proposed model is validated against the Keller models, with a resulting relative error of 2.3%. Field data from three ultra-deep wells are used to evaluate the performance of the wellbore heat transfer model, incorporating cementing quality. The results indicate that the mean relative error of bottomhole temperature prediction is 0.77%, while that of outlet temperature prediction is 3.06%. This work provides an accurate method for predicting wellbore temperature profiles in ultra-deep wells and offers technical support for temperature-controlled drilling.