Energy giant British Gas has been ordered to pay £5.6 million in compensation and fines for blocking business from switching suppliers and failing to tell others their contracts were ending, Ofgem said.

The company, one of the Big Six suppliers, had already paid £1.3 million to affected customers and will pay a further £3.45 million into an energy efficiency fund, plus an £800,000 penalty, the energy regulator said.

The payments come after two investigations by Ofgem into British Gas Business. The first, launched in 2012, found that a computer error meant 5.6% of objections it made to customers switching suppliers between 2007 and 2012 were "invalid".

The second found that around 1,200 mainly small business customers were not given notice that their tariff was about to expire.

Ofgem said British Gas had moved quickly to rectify the mistakes, something reflected in the amount it has been ordered to pay.

Sarah Harrison, Ofgem's senior partner in charge of enforcement, said: "The ability for consumers to switch easily and fairly is key to a well-functioning energy market.

"In these cases British Gas Business failed these consumers who were wrongly blocked from switching, many of them small businesses, and denied others the chance to switch to a better deal at the end of their contract.

"British Gas Business fully accepts its failings, has stopped the practices and corrected its processes to prevent this happening again.

"The company has taken responsibility for its actions and this package strikes a balance of penalty for the company and redress for affected consumers."

Some businesses are legitimately barred from switching suppliers, for example if they still owe money on an account.

But one of Ofgem's investigations found that in some cases computer problems were compounded by inadequate controls and poor communication with customers regarding why they were being blocked and how it could be resolved.

British Gas apologised and said it accepted the findings of both investigations.

It said it has already compensated current customers who were affected and it is tracing former customers to repay them as well.

Stephen Beynon, managing director of British Gas Business, said: "We're sorry these errors occurred and have worked swiftly to change our computer systems and processes, putting controls in place to stop this happening again.

"We take any failure to meet our obligations very seriously and will ensure that the new energy efficiency fund we have set up will be a real help to hundreds of small businesses.

"It will provide free expert advice and energy efficiency measures, such as new boilers, lighting and renewable energy, to help firms to manage their energy consumption and bills over the long term."