Defense Secretary Leon E. Panetta has ordered the Pentagon to find out why so many generals and admirals have become embroiled in legal and ethical problems, a trend exacerbated by recent investigations of two of the military’s best-known commanders.

The Pentagon disclosed Panetta’s directive on Thursday after he arrived in Thailand as part of a visit to Asia. But aides insisted that he had been considering the review for some time and that it was not prompted by revelations that the FBI has been investigating former CIA director David H. Petraeus, a retired Army general, and Marine Gen. John R. Allen, the commander of U.S. and NATO forces in Afghanistan.