In order to achieve a sustainable society, the energy consumption in buildings must be reduced. The first step toward achieving this goal is to detect their weak points and analyze the energy-saving potential. to detect the units with higher consumption and cost. Exergy is very useful for analyzing pieces of equipment, systems or entire buildings. It measures not only the quantity of energy but also its quality. If the exergy is combined with economic analysis, this gives rise to thermoeconomics, and the system can be checked systematically and optimized from the perspective of economics. In this work, exergy methods and thermoeconomic analysis were applied to a building thermal system. Due to its complexity, it is necessary to adapt some concepts to translate the exergy application from industry to buildings. The purpose of this work is to overcome these shortcomings and to deal with energy-saving actions for buildings. To this end, a thermoeconomic study of a facility that covers the heating and domestic hot water (DHW) demands of 176 dwellings in Vitoria-Gasteiz (Basque Country) using two boilers and two cogeneration engines was analyzed. The irreversibility associated with each piece of equipment was quantified, and the costs associated with resources, investment and maintenance were calculated for each flow and, consequently, for the final flows, that is, electricity (11.37 c€/kWh), heating (7.42 c€/kWh) and DHW (7.25 c€/kWh). The results prove that the boilers are the lesser efficient components (with an exergy efficiency of 15%). Moreover, it is demonstrated that micro-cogeneration engines not only save energy because they have higher exergy efficiency (36%), but they are also economically attractive, even if they require a relatively high investment. Additionally, thermoeconomic costs provide very interesting information and underscore the necessity to adapt the energy quality in between the generation and demand.