WASHINGTON—The Pentagon plans to keep some U.S. forces in Syria indefinitely, even after a war against the Islamic State extremist group formally ends, to take part in what it describes as ongoing counterterrorism operations, officials said.

There are approximately 2,000 U.S. troops in Syria, along with an unspecified number of contractors supporting them. Last month, the U.S. military withdrew 400 Marines from Syria, which U.S. forces first entered in the fall of 2016.

Officials...