He was an officer of the Army of the United States, where he swore an oath to protect the United States and its Constitution. Although he was also a citizen of Virginia, the status of statehood citizenship isn't legally that important (the Constitution implies that a citizen of one state is equal to the citizens of any other state, in those states, and so therefore state citizenship isn't important), and national citizenship supersedes state citizenship. He was still in the service of the US Army as of succession, and only afterwards decided to go with Virginia.