WASHINGTON—Before taking his new job as White House national security adviser in 10 days, John Bolton will have to wind down his multimillion-dollar political operation that is already in the thick of the 2018 election, according to the White House and an independent federal watchdog agency.

Under the 1939 Hatch Act, federal employees such as the national security adviser “may not campaign for or against candidates or otherwise engage in political activity” with partisan groups, according to the Office of the Special Counsel....