There is no specific law that explicitly states that the President must obey the orders of the US Secret Service. However, their authority over the President's movements comes from a combination of constitutional responsibilities, federal law, and national security protocols.
18 U.S. Code ยง 3056 - This law establishes the Secret Service's duty to protect the President, Vice President and others. While it does not explicitly state that the President must obey orders, it gives the agency broad authority to ensure their safety.
Presidential Succession and National Security Doctrine - As Commander in Chief, the President is considered a critical national security asset. Secret Service agents are expected to take whatever action is necessary to protect the continuity of government, even overriding the President's personal preferences in moments of crisis.
Precedent and Executive Orders - Over time, it has become standard protocol for the Secret Service to control the President's movements in emergencies. Past incidents have reinforced the expectation that agents have the final say in immediate security situations.
In contrast, presidential candidates receive Secret Service protection but are technically private citizens. While the agents strongly advise and attempt to control their movements in dangerous situations, a candidate is not legally bound to follow their orders. This means a candidate could theoretically refuse protection or ignore commands, although doing so would be highly discouraged.
https://www.law.cornell.edu/uscode/text/18/3056