Yes, they call this "geothermal" (although it's not like geothermal power generation). You can also use lakes and large ponds rather than burying it.
I looked into it last year. The main problem is cost (in getting into the ground) and expertise. In my area at least, there are dozens of reasonably solid residential HVAC companies with extensive traditional heat pump experience, and zero with extensive geothermal experience.