Some things to consider:
Soil temperature in temperate zones is about 12oC at 1.5m depth where the daily/seasonal temperature fluctuation is not noticeable anymore.
Water of 4oC is the heaviest and sinks, This creates thermoclines in lakes
Energy storage and recovery in the aquifer has been researched for greenhouses. Systems include pumps, wells, and heat exchangers to harvest heat or dump heat. One of the limiting factors is the water movement in the aquifer. One might lose one's heat sink. Geothermal systems with coils in the soil are widely used for home heating. Feasibility greatly depends on the price for energy in your area (the alternative, and electricity for pumps).