This prophecy probably came to Jeremiah after his interview with Zedekiah Jeremiah 38:14, but is added here as a supplement in order not to break the sequence of events.
Matthew Henry
Concise Bible Commentary
Here is a message to assure Ebed-melech of a recompence for his great kindness to Jeremiah. Because thou hast put thy trust in me, saith the Lord. God recompenses men's services according to their principles. Those who trust God in the way of duty, as this good man did, will find that their hope shall not fail in times of the greatest danger.
SDA Bible Commentary (limited)
Volume 1-7
15. While he was shut up.Verses 15-18 are a parenthetical account of God’s promise to Ebed-melech because of his kindness to Jeremiah.