Electricity is usually generated by turning heat into motion, which is then turned into electricity. You lose energy at each stage, but the heat to motion stage is limited by Carnot's Theorem, which puts an upper bound on the efficiency of heat engines. Efficiency varies based on implementation, but it almost never rises above 50%.
If you need heat, it's much more fuel efficient to just burn fuel and not bother turning it into electricity in an intermediate step.
If you need heat, it's much more fuel efficient to just burn fuel and not bother turning it into electricity in an intermediate step.