ANSWER: JOSEPH EGGLESTON JOHNSTON
Robert Edward Lee was offered a command in the Union Army by President Abraham Lincoln, and he turned it down. He could never take up arms against Virginia.
But the highest ranking officer in the U.S. Army to join the Confederacy was Brigadier General J.E. Johnston
Read more about it:
The Confederate Navy | A Book About Ships and Harbors by H.D. Ingles
A Stroll Through American History | U.S. History Milestones by H.D. Ingles