David Petraeus has apologised for conduct that led to his resignation as head of the CIA following the disclosure of an extramarital affair.

Mr Petraeus gave his first public speech since his resignation in November to a group of uniformed and decorated veterans at the University of Southern California's annual Reserve Officers' Training Corps dinner.

The hero of the Iraq and Afghanistan wars has remained largely in seclusion since resigning.

His lawyer, Robert B Barnett, has said that Mr Petraeus has spent much of that time with his family.

"Needless to say, I join you keenly aware that I am regarded in a different light now than I was a year ago," Mr Petraeus said.

"I am also keenly aware that the reason for my recent journey was my own doing.

"So please allow me to begin my remarks this evening by reiterating how deeply I regret, and apologise for, the circumstances that led to my resignation from the CIA and caused such pain for my family, friends and supporters."

Mr Petraeus received applause and a standing ovation before he began the evening's programme by cutting a cake with a sword in military tradition, a task reserved for the highest ranking person in the room.

The retired four-star general's affair with his biographer, Paula Broadwell, was discovered during an FBI investigation into emails she sent to another woman she viewed as a rival for his attention.

“I know I can never fully assuage the pain that I inflicted on those closest to me and a number of others," said Mr Petraeus, in a sombre tone to the audience that included his wife.

He also mentioned their children.

At the time the affair was made public, Mr Petraeus told his staff he was guilty of "extremely poor judgement".

"Such behaviour is unacceptable, both as a husband and as the leader of an organisation such as ours," he said.

Obama appoints female Secret Service director

Separately, US President Barack Obama has appointed veteran Secret Service agent Julia Pierson as the agency's first female director, a White House official has said.

In addition to protecting the president, the Secret Service also investigates financial crimes.

Ms Pierson, who most recently served as Secret Service chief of staff, will take over the top job from Mark Sullivan, who announced his retirement last month.

The agency faced intense criticism during Mr Sullivan's tenure for a prostitution scandal during preparations for Mr Obama's trip to Cartagena, Colombia, last year.

Thirteen Secret Service employees were caught up in the scandal.

After a night of heavy partying in the Caribbean resort city, the employees brought women, including prostitutes, back to the hotel where they were staying.

The incident became public after one agent refused to pay a prostitute and the pair argued about payment in a hotel hallway.

Eight of the employees were forced out of the agency, three were cleared of serious misconduct and at least two have been fighting to get their jobs back.