1. He said, "You promised me a bag of gold."

2. The old man said, "You promised me a bag of gold."
3. "You promised me a bag of gold," he said
4. "You promised me a bag of gold," said the old man.
5. "You promised me a bag of gold," said he.
=======================================
Are they all grammatical? Is #5 incorrect?

All are correct, yes. The phrasing in 5 would be used in something very formal or perhaps in a poem.

Be sure to put a period at the end of #3.