In order to reduce energy consumption and CO2 emissions in the building sector, more and more renewable energy sources are integrated into energy systems. Especially geothermal fields combined with heat pumps are able to supply buildings with heat and cold at low carbon emissions. However, using geothermal fields as heat and cold source influences the ground temperature. Consequently, the ground temperature can change dramatically over a building’s lifetime, leading to less efficient operation of the energy system. Therefore, a sustainable operation is required to ensure the long-term efficiency of geothermal fields. In this paper, we develop an optimization model to derive operating strategies for an efficient long-term operation of a building energy system coupled to a geothermal field. The investigated energy system is the main building of the E.ON Energy Research Center in Aachen, Germany, which includes a heat pump, two boilers, a combined heat, and power unit, a glycol cooler, and a geothermal field with 41 probes. For each component, we develop energy-based sub-models, which are connected to form the overall system. The geothermal field is modeled by using a g-functions approach as well as a simplified resistance-capacitance approach. To achieve short computing times and realize an optimization horizon of several years, the optimization problem is formulated as mixed-integer linear programming (MILP). The developed model is optimized regarding two different objectives: the minimization of energy costs and the minimization of long-term temperature changes in the ground. Conclusions for an efficient and sustainable operation of the field, especially for the cooling supply, can be derived from the optimization results. It is shown that a state of equilibrium should be aimed to achieve an energy-efficient operation, in which the temperature of the field is close to the initial ground temperature.