Bank of America Corp., the second- largest U.S. lender, agreed to an $8 million fine and returned almost $90 million to clients of its Merrill Lynch unit who were improperly charged fees over six years.

About 6,800 retirement plans for charities, ministers and public-school workers and 41,000 for small businesses paid purchase charges for mutual funds when none was required from 2006 to 2011, according to the Financial Industry Regulatory Authority.

While Merrill Lynch discovered the improper charges in 2006, it didn’t inform Finra until 2011, according to settlement papers released today.

Bank of America inherited an array of legal and regulatory disputes with takeovers of Merrill Lynch & Co. and Countrywide Financial Corp. during the financial crisis. Chief Executive Officer Brian T. Moynihan, whose tenure started in 2010, has set aside more than $55 billion for mortgage-related issues alone. Merrill Lynch was acquired by Charlotte, N.C.-based Bank of America in 2009.

The brokerage failed to supervise or properly train its advisers about the lowest-cost mutual fund shares, Finra said. The firm relied on the advisers to waive mutual fund charges, which they didn’t always do, according to Finra. Bank of America didn’t admit or deny the findings by Finra, the industry’s self- policing body.

“Following Bank of America’s acquisition of Merrill Lynch, we concluded that certain Merrill Lynch clients did not receive fee waivers for which they were eligible,” Bill Halldin, a Bank of America spokesman, said in an e-mail. “We notified Finra about our findings and voluntarily began making refunds.”

The firm was ordered to pay $24.4 million in restitution to clients, on top of the $64.8 million it already returned, according to Finra’s statement.