This paper presents a method for choosing the energy sources that are needed for the following building utilities following building: lighting, domestic hot water, heating, ventilation, and air conditioning. The novelty of this paper consists of applying the concept of the energy hub and considering the cost of carbon dioxide emissions when selecting the available energy sources in the building's location. The criterion for selecting the energy sources is the minimum overall cost of all forms of energy that are consumed in the building over its estimated lifetime. In order to estimate the overall costs, it is necessary to know the power that is installed and provided by the energy production technologies that are inside the building, as well as the capacity of energy that is required from outside energy sources. An office building that was proposed for refurbishment has been investigated as a case study. In the paper, we have analysed four scenarios. The results indicate that more favourable alternative solutions can be obtained compared to the traditional scenario (Scenario 4-heat and electricity by public utility networks). The overall costs are 46.17% (212,671 EUR) lower in Scenario 1, 25.35% (116,770 EUR) lower in Scenario 2, and 10.89% (50,150 EUR) lower in Scenario 3. Additionally, the carbon dioxide emissions are 22.98% (49 tonnes CO 2 /year) lower in Scenario 1 and 8.91% (19 tonnes CO 2 /year) lower in Scenario 2. Thus, renewable energy sources can occupy a growing share of the total energy consumption of the building. The proposed algorithm can be used for both the refurbishment of existing buildings and the design of new buildings.