in the specific context of living off-grid, heat pumps make great sense because the amount of electrical energy put in is a fraction of the amount of heat energy moved. This is the crux of the cost argument - electricity is expensive whether from the grid or from your own sources. The original point was that electricity is wasteful for heating. It is not.
Your numbers for grid efficiency are also way off. Hydro and nuclear to name just two, are much more efficient than that and 40% efficiency numbers are in the realm of possibility where the grid is primarily coal-based. Which most of north america and europe are not.
Efficiency is hard to measure because there's such a mix of fuels. Hydro is very efficient, but also a very small part of the generation mix in most places. Nuclear is pretty hard to measure - the actual thermodynamic efficiency of extracting electricity from heat is around 33%, but obviously as that heat doesn't come from fossil fuels it's pretty hard to compare.
One way you can look at the grid as a whole is by comparing the average carbon intensity of a delivered kWh of energy with the carbon released by burning when generating the same amount of heat energy. There's a good map of different countries [1]
We can compare that with a hydrocarbon fuel like natural gas, which has a CO2 emission of 66.7 kgCO₂/GJ [2]. That's 66.7 gCO₂/MJ or 240 gCO₂/kWh
Interestingly, quite a few grids have an "efficiency" (including renewables) of greater than 100%. As an example, the UK national grid had a carbon intensity in 2020 of 181 gCO₂/kWh - meaning using a kWh of energy from the grid releases only 75% of the CO2 that getting that energy from burning gas would.
Others are less good - eg Queensland in Australia is at 703 gCO₂/kWh, giving an "efficiency" of 34%
This of course includes all the renewables which are pushing up the number. I'd expect it to also include the transmission losses. Interestingly for most countries it's higher than I would have guessed - obviously the ~20-30% renewables and nuclear is pulling up the efficiency.
So in summary - I was wrong. The grid is often (depending on your region) a better place to get energy from (in CO2 terms anyway), even if you're just burning it with resistive heat.
Your numbers for grid efficiency are also way off. Hydro and nuclear to name just two, are much more efficient than that and 40% efficiency numbers are in the realm of possibility where the grid is primarily coal-based. Which most of north america and europe are not.