Ms Harman, standing in for Gordon Brown during prime minister's questions due to his visit to Iraq, was responding to a question from Labour MP Brian Donohoe, who claimed it was "surely" time for energy prices to fall.
She told the House: "The energy companies must pass on the price cuts to consumers - both businesses and families. They must also treat all consumers fairly.
"And, if they don't, it won't just be Ofgem and the Competition Commission they'll have to worry about. We will change the law to force them to do it."
Ed Mayo, the chief executive of Consumer Focus, said earlier this week that Ofgem must make reducing energy bills for consumers "a priority".
Click here to run an energy price comparison, and see if you could be paying less for your gas and electricity.