“Whoever, except in cases and under circumstances expressly authorized by the Constitution or Act of Congress, willfully uses any part of the Army or Air Force as a posse comitatus or otherwise to execute the laws shall be fined under this title or imprisoned not more than two years, or both.”The insurrection act is an exception allowing the President to use the troops under certain circumstances,
The Insurrection Act (Title 10 USC, Sections 331-335). This act allows the president to use U.S. military personnel at the request of a state legislature or governor to suppress insurrections. It also allows the president to use federal troops to enforce federal laws when rebellion against the authority of the U.S. makes it impracticable to enforce the laws of the U.S.Last used I believe in 1992 during the LA riots.
From NORCOM's website.