The building envelope structure is the cause of a major part of energy consumption, with exterior walls and windows being the main energy-consuming components. Traditional building energy conservation measures often overlook the demand for human comfort, especially in areas characterized by hot summers and warm winters. For this paper, the authors concentrated on indoor comfort, with a focus on optimizing the heat transfer coefficient of windows and exterior walls using a genetic algorithm. They used a genetic algorithm to explore the performance optimization of exterior walls and windows in the enclosure structure. To aid this effort, they constructed a building energy-saving optimization model. In addition, they created an optimization model in an attempt to reduce building energy consumption. They took the heat transfer coefficients of the outer window and the outer wall as the optimization parameters of the established model, and they compiled the optimization program using MATLAB. The experimental results showed that the heat transfer coefficients of exterior walls and windows in cold regions are 0.4459 and 2.7875, respectively, while the heat transfer coefficients in warm winter and hot summer regions are 0.66, 1.98, 1.026, and 1.59. The conducted work provides a reference for the optimization design of the heat transfer coefficient of external walls and windows as a measure to enhance building energy efficiency.