For years, customers have complained that energy firms can hoard thousands of pounds of overpayments and would only return it on request.
Now the regulator has proposed balances are cleared once a year, claiming suppliers held a surplus of £1.4bn.
It said some were using the money for "unsustainable business practices".
Energy UK, which represents suppliers, said direct debits evened out bills even though domestic gas and electricity use varied considerably during the year.
For the millions of customers paying by direct debit, energy firms set a sum to be collected each month. The amount is based on predictions of how much gas and electricity will be used, taking previous records into account.
Often the balances go into credit in the summer, when less energy is used, before moving back closer to parity during the colder months
However, meter readings may show that direct debits have been set too high, meaning a customer has consistently overpaid.
This can build up, in some cases, to thousands of pounds. In 2016, the BBC reported how one customer was shocked to discover that his energy supplier owed him £3,049 - with similar complaints having been made for years.
Current rules state the onus is on the customer to request a refund of the money. The process can take months.
Now, Ofgem has proposed that, from next year, companies automatically refund customers on the anniversary of the start of payments or their contract.
That would mean a customer who signed up with a firm in April, for example, would see their excess balance the following April automatically refunded into their bank account.
Ofgem estimates that people would receive £65 on average, under the latest calculations.
"These new proposals would ensure that suppliers are not holding onto more of customers' money than absolutely necessary, potentially returning millions of pounds of customers' money," said Jonathan Brearley, chief executive of Ofgem.
"This is an important step in making the retail energy market fairer for consumers at a time when many are facing financial hardship."
The regulator said it had evidence that excess payments were being used by some suppliers to prop up parts of the business that would otherwise be unsustainable.
To prevent firms simply increasing direct debits during a year, the regulator is proposing a threshold for these payments. The methodology will be discussed during consultation.
Any customers who owe money at the end of the year will, as is currently the case, receive a catch-up bill or see regular direct debits increased over the following year.
The Energy Ombudsman received 1,000 complaints about credit balances last year.
"Just as people are expected to pay their energy bills on time, we think it's fair to expect energy suppliers to do the same with refunds," said Ed Dodman, director of regulatory affairs at the Energy Ombudsman.
"We know from looking at complaints that suppliers can sometimes take too long to issue refunds, which can be stressful for consumers."
On behalf of suppliers, Energy UK said: "Paying by direct debit helps customers budget by ensuring they pay a regular amount each month even though their actual energy usage varies significantly over the year.
"Some suppliers already refund credit balances automatically so we now need to look in detail at Ofgem's proposals."
Customers who pay too much to their energy supplier through their monthly direct debit payment should receive automatic annual refunds, Ofgem says.