The U.S. Securities and Exchange Commission's top inspector, Lori Richards, is leaving the agency after a year in which her office and the enforcement division was accused of failing to spot Bernard Madoff's $65 billion fraud.

Richards, the first director of the compliance inspections and examinations unit, plans to leave August 7, the SEC said on Wednesday.

Her departure comes about four months after Linda Thomsen resigned as the SEC's enforcement director. Both were blasted at a congressional hearing over how the agency failed in the Madoff case.

Some SEC watchers said singling out the two women was unwarranted given that Madoff's fraud spanned several decades.

The Office of Compliance Inspections and Examinations (OCIE) was created in 1995 under former Chairman Arthur Levitt and has been criticized as ill-conceived and unable to effectively examine Wall Street.

Richards served the SEC with dedication for many years, former SEC Chairman Harvey Pitt said.

Unfortunately, the paradigm established by the SEC for examinations ... was fatally flawed, and contributed to commission examiners' inability to find many of the market problems that have occurred since then, Pitt said.

Pitt was SEC chairman when the Enron scandal broke.

OCIE staff examines thousands of registered entities such as broker-dealers, investment advisers, mutual funds, transfer agents among others. The examinations are designed to detect fraud and securities violations and ensure compliance with securities law.

The office examined Madoff's broker-dealer operation -- most recently in 2004 and 2005 -- but found no fraud.

Richards has spent more than two decades at the SEC in various capacities including administrator for the agency's enforcement program in Los Angeles and senior adviser to Levitt.

Richards said she first started talking about leaving in May but wanted to stay to implement changes to her office.

When asked whether any of the criticism played a part in her decision to leave, Richards said: Absolutely not.

I have been focused for 14 years on making the exam program as vigorous as it could possibly be to provide oversight of the securities industry, she said in an interview.

Other top SEC officials have departed since Schapiro took the helm late in January. Such changes are customary when a new administration takes over.

The division's associate director and chief counsel John Walsh will serve as its acting director when Richards leaves.

(Reporting by Rachelle Younglai, editing by Gerald E. McCormick, Leslie Gevirtz)