The word "heir" can be used with an article or without.
Prince William is the heir to the throne of the United Kingdom.
Prince William is heir to the throne of the United Kingdom.
As Colin Fine pointed out in a comment, this same pattern holds true for many nouns that describe roles or positions of power:
Bob is chairman of the school board.
Mary is captain of this ship.
Bill Gates was CEO of Microsoft for many years.
Louis XIV became king of France in 1661.
The use of "heir" without an article dates back at least as far as Shakespeare:
To be or not to be—that is the question:
Whether ’tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles
And, by opposing, end them. To die, to sleep—
No more—and by a sleep to say we end
The heartache and the thousand natural shocks
That flesh is heir to—’tis a consummation
Devoutly to be wished.
—Hamlet, Act 3, scene 1
If an article was needed, then Shakespeare would have written "that flesh is the heir to". But he didn't.
You cannot say:
I am son of John.
I'm son of John.
Native speakers do not omit the the article in those sentences.
"I'm the son of John" and "I'm a son of John" are both technically correct, but not widely used.
In almost every case, a native speaker would use a possessive instead:
I'm John's son.
There is one special case where you can use "son of" without an article. If you are an character in a story set hundreds of years ago, you might introduce yourself by listing your ancestry:
I am Robert, son of John, son of Henry, son of ...
But nobody talks like that in the modern day.