The only reason gas is used for heating is the historical cheap price for gas. Gas line and gas infrastructure is actually a bit expensive and require additional maintenance compared to just running electrical lines between homes, and gas heaters are generally a bit more complex to install than electric heaters. The incentives to continue with gas heaters goes down when gas prices goes up, in similar way that the incentives for electric heaters will go down when the electricity prices goes up.
If we compare Sweden to Germany, almost no homes in Sweden has gas lines connected to them. Swedish homes use heated up water (central or communal heating), or just heat up the air. Sweden has a lot of nuclear and hydro so the electricity prices has historically been low, and importing gas would be expensive. There have been few incentives to spend money and government resources into the infrastructure needed for gas. Germany in contrast seems to have done the opposite, with historical low prices for gas (didn't the coal industry produce also produce gas in the past?), and fairly high prices for electricity. By now there is a pretty large sunk costs into gas infrastructures, and a switch to electric heating would be both expensive for the government and for individual home owners.
On the positive side, a massive investment towards electric heating would be a major boon for the environment. Leaks from natural gas is considered a major contributor for green house gases, and burning it also not very good.