I have heard that geothermal heating is a way of generating energy from the temperature difference between the inner layers of the Earth and the Earth's crust. How is it possible to extract this energy? Must one be near a tectonic plate boundary to gain access to this temperature gradient?
To explain the earth science bit (how a heat exchanger works is beyond the scope of the site). The Earth is essentially cooling, losing heat from the interior by conduction to space. this heat flux can be used to heat, for example water at depth since temperature increases with (significant) depth in the earth's crust. It is not necessary to be near a plate boundary although such locations may have anomalously large heat fluxes. A good example is Iceland. For an igneous plate, heat fluxes may average just above 40 milliwatts per square meter. In addition to pure heat flow out from the crust, heat is also generated within the bedrock due to radioactive decay. Measurements in Scandinavia shows that heat fluxes may vary between 30 and 82 miliwatt per square meter (Näslund et al. 2005).
Hence there is an from a human perspective inexhaustible energy source that can be tapped into. the point is to use the ground eat to warm some liquid, usually water and use a heat exchanger (essentially a reversed refrigerator to extract, for example, heat for heating or hot water.
Näslund, J., Jansson, P., Fastook, J., Johnson, J., & Andersson, L. (2005). Detailed spatially distributed geothermal heat-flow data for modeling of basal temperatures and meltwater production beneath the Fennoscandian ice sheet. Annals of Glaciology, 40, 95-101. doi:10.3189/172756405781813582
There are currently two ways to extract geothermal energy: one mainstream, one still at the experimental / demonstration level.
Pollack et al (2010) estimate the global geoethermal heat loss at 44 TW (by comparison, civilisation's rate of energy use is about 20 TW).
As the USA Department of Energy notes, all methods rely on the combination of three factors:
- heat underground,
- fluid to carry the heat to the surface, and
- permeability to allow the fluid to flow.
The mainstream geothermal method
This happens close to tectonic plate boundaries. Reservoirs of hot liquid are tapped, to bring the hot fluids to the surface. Typically the temperature of the fluids is well over 100 °C;, and can be used for electricity generation, as well as for heating.
The experimental method is Hot Dry Rock
aka Enhanced Geothermal System or EGS.
As Pavel V. commented, this is being piloted in the Czech Republic, amongst other places, and allows geothermal heat extraction from places that are not close to tectonic plate boundaries. From that link:
the projected depth of the ... borehole was between 2100 and 2500 m. The drilling diameter ranges from 393,7 mm for the starting upper section to 152 mm at the borehole bottom
One tube is placed inside another, inside the borehole. Water can be injected down the inner tube, and returned up through the gap between tubes, or the other way around.
That paper reproduces the following chart from Šafanda, J., Dědeček, P., Krešl, M., Čermák, V.  Report from geothermal research for PVGT-LT1 (in Czech):
As you can see, these temperatures are much lower, so are unsuitable for electricity generation, because one must accept very low efficiencies (Carnot's Law). They are used for space- and water-heating.