First off, the teacher was a substitute. For whatever that's worth, they didn't know the kid.
An observation: An oath taken under duress is not binding, is meaningless.
If the kid objected, note it. Even ask the kid why. Make that a topic of class discussion, the oath, what it means to others there-- Why swear allegiance to the American flag? Likely most of those kids are more in love with the Republic for which it stands (under God--Is that still in there?), with Liberty and Justice for all, and can express reasons why.
Discuss the concepts of Liberty, of Justice, and how/why the kid considers the flag racist--let the kid express why they think it racist, and then demolish that with some simple facts. Better yet, let the other kids do that.
Being a sub, I would think they could get away with spending at least part of a day on that.
Might even change the kid's mind--at least give them something to think about.
Looking at what happened (as related in the press), I seriously doubt the kid will be any more inclined to stand, hand over their heart, and voluntarily recite that oath. Especially if the teacher or anyone else exaggerated or fabricated any account of a threat and the child is disciplined for that and did not make one.
I see this as a lost opportunity to bring the kid around, an attitude on the kid's part that could have been changed by a wiser teacher, instead of reinforcing whatever imagined issue the kid had with badgering and disciplinary action for not taking a voluntary oath.