When the heat is provided by electricity, the electricity, including the heat, can be submetered. That's not a problem. What I'm addressing here is the notion that the landlord has a central boiler—usually a boiler, which is usually natural gas-fired, but it could be oil—and then the boiler emits hot water. The hot water then goes to the different apartments.
If this problem were solved, the flow and the temperature of the water being delivered to each apartment could be measured, and then the cost, and then there'd be a carve-out for the common areas for that piping, or just the residue would be left with that. The cost of the oil or natural gas could then be charged to the users.