Bank of America is being accused of stiffing the FDIC, the government agency that insures people's deposits against a bank failure.

The FDIC filed a lawsuit in federal court on Monday demanding that Bank of America pay $542 million it owes to the regulator's deposit insurance fund.

"Because Bank of America refuses to pay, the FDIC seeks relief from this Court," the suit in federal court in Washington said.

The reason: Bank of America (BAC) underreported a key risk metric by tens of billions of dollars during the final three quarters of 2013 and all of 2014, the lawsuit said. The FDIC said that allowed BofA to appear less risky than it really was -- and avoid paying the FDIC an average of $77 million each quarter into the agency's deposit insurance fund.

The FDIC insures customers' deposits up to $250,000 in case a bank collapses. That's why even though hundreds of banks went belly up during the 2008 crisis, Americans didn't lose money that was kept in FDIC-insured accounts.

Banks of all sizes must pay into the insurance fund, which currently has nearly $81 billion.

The FDIC said this is the first time it has filed suit against a bank to recover insurance fees in more than two decades.

Related: Wall Street hates the Volcker Rule. Will Trump kill it?

The insurance premiums are calculated based on the risk level of banks. Not only do the banks have to spell out their own risk exposure, but also those of their business partners.

A 2014 FDIC rule change requires big banks to add up their total exposure to business partners by their parent company rather than by individual entity. For instance, Goldman Sachs has to break out its total exposure to all of Facebook (FB) instead of listing individual subsidiaries like Instagram and WhatsApp.

The thinking is that banks with more concentrated "counterparty" exposure are at more risk of getting into financial trouble.

The FDIC said Bank of America failed to divulge this risk. The lawsuit said Bank of America was the only bank, out of the nine that are required to do this, that failed to report this kind of exposure.

Bank of America, however, disputes the FDIC claims. It said in a statement there is a "technical disagreement" over the 2014 rule change but that it believes it's in compliance.

"We look forward to the court's review," the bank said.

Related: Wells Fargo giving raise to 25,000 workers

Eugene Scalia, a lawyer from Gibson Dunn who represents Bank of America, questioned how the FDIC could have been unaware of the bank's approach to this issue.

The FDIC "received reports from the bank each quarter which made crystal clear what approach the bank was taking," Scalia said.

Bank of America and the FDIC had been in talks about the issue. "They agreed to provide us additional information, but recently they indicated that they felt they must file suit by mid-January," he said.

It's unclear if the FDIC wanted to file the lawsuit before the arrival of President-elect Donald Trump, who has promised to dial back regulation, including on banks.

A person familiar with the FDIC's thinking said the lawsuit was triggered by a statute of limitations issue, not a change in administration.