In 1989, the United States Supreme Court ruled that burning or desecrating a flag was a protected expression, and therefore legal, under the First Amendment. As of 2015, that ruling stands, but flag desecration hasn't always been protected by the Constitution, and there are plenty of efforts throughout history to outlaw it.
In 1984, Gregory Johnson traveled to Dallas, Texas, to protest Ronald Reagan and the Republican National Convention. While marching with several protesters, Johnson poured kerosene on an American flag and lit it on fire. He was promptly arrested, then charged with and convicted of violating a Texas law that prevented "the desecration of respected objects."
But Johnson appealed the conviction on the grounds that the Texas law was suppressing his right to free speech. The case was overturned, and that's when Texas appealed and took it to the Supreme Court. In 1989, with a landmark ruling of 5-4 in the case of Texas vs. Johnson, the Supreme Court said that the flag burning was a form of symbolic speech protected under the First Amendment.
It's important to note that this ruling doesn't necessarily change any state or local laws, and restrictions can still be placed on when and where these kinds of protests are allowed. In other words, the issue (like a lot of legal issues in America) is still open to interpretation and change.
Since Texas vs. Johnson through 2015, there have been six attempts to pass constitutional amendments that prohibit the physical desecration of the flag (which, of course, includes burning). The most recent attempt, in 2006, fell short in the U.S. Senate by a single vote. So while there seems to be legal certainty on the matter for now, it can always be considered "subject to change."