The Supreme Court has found procedural grounds to punt the issue and has never actually ruled on the merits.
http://www.cnn.com/2004/LAW/06/14/scotus.pledge/
You are correct that it was not the establishment clause that had been used against requiring someone to say something against their religious principles. It was the free speech part of the First Amendment that prevents this.
I was surprised to learn that the Supreme Court first ruled 8-1 in 1940 that it was OK to force a child to pledge to the US flag. Then three years later the Court reversed itself. From a description of the later case (Source):
The Court held that the right of free speech guaranteed in the First Amendment to the Constitution means the government cannot force anyone to salute the American flag or recite the Pledge of Allegiance. Forcing people to have similar opinions was doomed to failure, and violated First Amendment principles: "If there is any fixed star in our constitutional constellation, it is that no official, high or petty, can prescribe what shall be orthodox in politics, nationalism, religion, or other matters of opinion or force citizens to confess by word or act their faith therein."