WASHINGTON — Health and Human Services Secretary Kathleen Sebelius violated a federal law that restricts political activity by government officials, a federal ethics office said in a report Wednesday.

Off-the-cuff remarks by Sebelius during a speech earlier this year to a gay rights group in North Carolina violated the Hatch Act, the US Office of Special Counsel said in a report to the White House. The law prohibits federal employees from using their official authority to influence an election, although it allows partisan remarks made in a personal capacity.

In the Feb. 25 speech to the Human Rights Campaign, Sebelius called for President Barack Obama’s re-election and endorsed a Democratic candidate Walter Dalton for governor. Later, she rescinded the gubernatorial endorsement.

The ethics office found that Sebelius had made the speech in her official capacity as the nation’s top health official, but departed from her prepared text and veered into politicking.

“While a violation of the Hatch Act occurred, Secretary Sebelius’ statements would have been permissible if they had been made in her personal capacity,” the report said.

In a formal response, Sebelius said that any violation was “technical and minor” and was corrected after her official trip was reclassified as political, and the government was repaid for her travel.

“It seems somewhat unfair to conclude that, as a result of my offhand statements, I used my official title for political purposes,” Sebelius wrote.

The Democratic National Committee reimbursed the government $2,514.50 for the portion of the trip that was deemed political, said Ann O’Hanlon, a spokeswoman for the ethics office. That amount covered expenses for Sebelius and an aide, and was approved by the ethics office. An aide to Sebelius said the secretary flew on a commercial airline.

Since Sebelius is a Cabinet official, the ethics office referred the case to the White House for “appropriate action.” It made no recommendation as to what that should be.

Although Hatch Act violations can be a firing offense for federal employees, it appeared unlikely that Sebelius would be disciplined.

“These were extemporaneous remarks … the US Treasury has been reimbursed, and Secretary Sebelius has met with ethics experts to ensure this never happens again,” said White House spokesman Eric Schultz.