Yes, according to the Federal Aviation Administration (FAA), there must always be two people in the cockpit of a US airline flight.
This is for safety reasons and to ensure that if something were to happen while one person was out of the cockpit, another qualified individual would be present.
Flight attendants are trained in emergency procedures and can enter the cockpit when needed.
So yes, if a pilot leaves their seat during a US airline flight then at least one other person must enter the cockpit until they return.
Source: Quora