Ofgem has called on energy suppliers to return money to former customers after finding that the companies hold more than £400 million in credit from closed accounts.
The regulator found large companies hold at least £202 million from around 3.5 million former domestic customers and £204 million from 300,000 business accounts, saying it "expects suppliers to do more" to return the money.
It follows recent commitments by most major suppliers to automatically refund surpluses to current direct debit customers.
Ofgem said it had been inquiring into the balances held by energy suppliers, and into the companies' policies and practices, concerning customers who had closed accounts.
It found "an unacceptably large amount of money being retained rather than returned to consumers" and a wide variation in company practices.
The regulator said consumers needed to be confident that they would not lose out if they closed an account with their present supplier.
It expected suppliers to do all they could to return money to individual consumers, and to tell consumers clearly what to do when closing an account.
Where it was not possible to repay a balance, it said suppliers should find ways to use the money to benefit consumers more widely and be clear in communicating their plans.
It said suppliers' policies and processes must prevent such large sums being retained by them, with "crystal-clear communication" to consumers about what to do when closing an account.
And Ofgem added: "We are looking at whether suppliers' current policies and practices relating to giving money to individual customers are fully compliant with existing rules including those requiring companies to treat consumers fairly.
"Our advice to consumers who believe they may still be owed money by a previous supplier is to contact the company directly and ask for it back."
Ofgem interim chief executive Andrew Wright said: "When many people are struggling to make ends meet, it is vital that energy companies do the right thing and do all they can to return this money and restore consumer trust.
"We want to see decisive action by suppliers, individually and collectively, to address this issue and, wherever possible, to ensure that the balances they currently hold are returned to consumers.
"Where this can't be done, any remaining sums should be used to benefit consumers more generally, and suppliers need to be very clear with consumers about what they will be doing with this money."
Ofgem advised consumers who had switched away to another company or changed tenancy to get in touch with their former supplier, preferably with a copy of the previous bill.
Those who thought a deceased relative may have been an account holder and were pursuing a closed account would need to demonstrate entitlement to any proceeds of the estate.
It also urged those about to switch supplier to take a meter reading just before doing so and give a forwarding address to the company they were leaving.
A spokesman for Energy UK, the trade association for the energy industry, said energy companies try to ensure customers money gets back to them, but that more commonly energy companies are owed many times more money by people who leave unpaid debts behind them.
He said: "Although companies are working to return money where there are credit balances sometimes former domestic customers provide no new contact details so suppliers don't know how, or to whom, they can return the money.
"The most common reasons energy companies end up holding funds are when the bill payer has moved home or when a customer dies and suppliers have no record of the next of kin.
"Suppliers already agreed with ministers last year that they would take all reasonable steps to trace customers who leave a credit balance behind."
He added: "If you think you may be owed money, get in touch with your supplier past and present, to check if they have funds to return to you."
Richard Lloyd, executive director of consumer group Which?, said: "If true, it's shocking that some of the biggest energy companies are sitting on millions of pounds worth of consumers' cash.
"Suppliers must return this money as soon as possible and be clear about what customers need to do when they close accounts.
"We look forward to seeing the final conclusions of Ofgem's investigation, and quickly."
British Gas director Ian Peters said: "British Gas will always provide a full and immediate refund to customers for any sum owing to them, whenever we can contact them. Even if they are owed as little as a pound, we will always give them their money back, no matter how long ago they left us.
"We go well beyond our legal obligations to actively seek out customers owed money in order to return it, contacting them by phone, letter, and, after multiple attempts, we also use specialist agencies to help trace customers to refund the credit.
"Since 2012, we have sent more than 32,000 letters, made 18,000 outbound calls and received over 16,000 calls, successfully returning money to 10,000 customers.
"However any credit owed to customers is significantly outweighed by the value of customer debt. At September 2013, the amount owed to household customers was £40 million, with customer debt five times that amount, at almost £200 million."Suggest a correction