WASHINGTON — The White House has ordered a review of how officials accidentally revealed the name of the Central Intelligence Agency’s top spy in Afghanistan during President Obama’s surprise trip to the country over the weekend.

Denis R. McDonough, the White House chief of staff, has asked W. Neil Eggleston, the president’s top lawyer, to “look into what happened” and to recommend changes that would prevent similar mistakes, officials said.

The name of the C.I.A. station chief in Afghanistan was accidentally disclosed on Sunday morning when military officials sent a White House press aide a list of 16 people who were participating in a briefing with Mr. Obama. One of the participants was identified as “chief of station.” That title refers to the highest-ranking C.I.A. officer in a country.

The New York Times is not naming the C.I.A. chief at the request of the White House and C.I.A. officials.