Ofgem found that EDF Energy had opened up phone and doorstep sales conversations by claiming the customer could save money by switching to EDF without knowing the circumstances of the customer.
However, an Ofgem spokesman claimed this did not mean EDF deliberately had a policy of mis-selling to customers.
The settlement includes a £1 penalty, which Ofgem was obliged to impose, with the remaining £4.5m being in lieu of a fine.
If a fine had been imposed the money would have gone directly to the Treasury rather than back to EDF customers.
An Ofgem spokesman said this was the largest settlement with an energy firm that has been paid to customers.
Of the £4.5m package, £1m will be donated to support the Energy Best Deal public awareness campaign run by Citizen's Advice, which encourages people to shop around to find the best deal and get help if they are falling behind with energy payments.
The remaining £3.5m will be credited to the bills of vulnerable customers who qualify for the government's Warm Homes Discount.
EDF has around 70,000 customers who qualify for the Warm Homes Discount, meaning they will receive around £50 each.
Sarah Harrison, senior partner at Ofgem, said: "EDF Energy has done the right thing by stepping forward and recognising there were weaknesses in its sales processes.
"This is an important step forward and demonstrates a commitment by EDF Energy towards re-establishing consumer trust which we welcome."
Martin Lawrence, managing director of EDF’s energy sourcing and customer supply unit, said: "We're obviously disappointed that we failed to live up to the high standards that we expect of ourselves.
"As soon as the issue was identified we immediately took action to satisfy ourselves that we're fully compliant."
Ofgem is also in the process of investigating the sales practices of Scottish and Southern Energy, nPower and Scottish Power.
Follow Matthew Chapman at @mattchapmanUK
This article was first published on marketingmagazine.co.uk