Two police officers in Gretna, La., were fired on Monday, four days after one of them referred to Representative Alexandria Ocasio-Cortez as a “vile idiot” on social media and suggested that she should be shot.

Chief Arthur Lawson of the Gretna Police Department announced the terminations, saying that Charles Rispoli, the officer who wrote the Facebook post, and Angelo Varisco, who liked the post online, had violated the department’s social media policy.

“This incident, we feel, has been an embarrassment to our department,” Chief Lawson said at a news conference. “These officers have certainly acted in a manner which was unprofessional, alluding to a violent act to be conducted against a sitting U.S. congressman, a member of our government. We’re not going to tolerate that.”

Mr. Rispoli, a 14-year veteran of the Police Department, said in a Facebook post on Thursday that Ms. Ocasio-Cortez “needs a round — and I don’t mean the kind she used to serve,” a reference to her past work as a bartender, according to a screenshot of the comment obtained by The Times-Picayune of New Orleans.