Ovo Energy and Good Energy are set to pay out £2.7million to thousands of customers who were overcharged.
Some households were charged above the maximum rates allowed under either the Ofgem price cap or the Government Energy Price Guarantee.
Both schemes are designed to cap the unit rates you’re charged for gas and electricity, as well as the standing charges.
Ofgem said it was "totally unacceptable" people were overcharged during an "already so challenging and stressful time" after energy bills soared in price.
Households are currently covered by the Energy Price Guarantee with the average bill standing at £2,500 a year for someone with typical energy use.
The energy watchdog said almost 18,000 households did not receive protection they were due.
Good Energy overcharged more than 6,900 customers between January 2019 and October 2022.
Ovo overcharged nearly 11,000 customers between October 2022 and March 2023.
Good Energy customers will be paid £109 on average, while Ovo customers will receive an average of £181.
Both energy firms will also pay £1.25million to the voluntary redress fund, which helps vulnerable customers in the UK.
Dan Norton, deputy director of retail at Ofgem, said: "Protecting consumers is always our top priority, and we expect suppliers to ensure customers pay no more than the level of the price cap or Energy Price Guarantee - schemes put in place with the very purpose of helping people.
"It is totally unacceptable that Good Energy and Ovo Energy customers were overcharged, particularly at a time that is already so challenging and stressful for consumers across the UK.
"Energy suppliers should hear this loud and clear: we expect suppliers to act with the utmost care and integrity.
"We will continue to hold them to account if they do not meet their customer protection or reporting obligations."
Both suppliers self-reported the issues to Ofgem.
A spokesperson for Ovo said: "We're very sorry to some of our fixed-price customers who experienced a delay in receiving the Energy Price Guarantee discount. We noticed immediately and self-reported the error to Ofgem.
"The issue has now been fixed and compensation has been paid as an apology."
Nigel Pocklington, Good Energy's chief executive, said: "We are very sorry that we let some of our customers down and promise to put things right.
"We have been contacting those impacted to apologise and issue their refunds and goodwill payments and will be fixing the issue so it does not happen again."