Is there a way to know according to Scripture, whether King Solomon is in Heaven or Hell?
The testimony of Scripture is that Solomon was a believer. First, the text states so plainly:
1Kings 3:3 Now Solomon loved the LORD, walking in the statutes of his father David, except he sacrificed and burned incense on the high places.
Secondly, Solomon authored at least three books of Scripture (Song, Proverbs & Eccl), which would have been impossible were he not a believer and under the anointing of the Spirit of God.
Thirdly, the king is in the line of Jesus and there are no unbelievers in Jesus' family line:
Matt. 1:7 Solomon was the father of Rehoboam, Rehoboam the father of Abijah, and Abijah the father of Asa.
Finally, Solomon was greatly used and blessed by God, and though he also sinned greatly, he turned back to a relationship with His Lord. As King David lay on his death bed, he spoke to Solomon:
1 Kings 2:3 Keep the charge of the Lord your God, to walk in His ways, to keep His statutes, His commandments, His ordinances, and His testimonies, according to what is written in the Law of Moses, that you may succeed in all that you do and wherever you turn,
David tried to encourage his son to not only obey the Lord, but to "walk" with Him – have a relationship with Him. We see evidence of this relationship in the times when God communed with Solomon (granting Solomon's request for wisdom and blessing him with wealth and fame in return, granting Solomon the privilege to rebuild the temple). Yet then his many wives entered the picture, and like many who lust after the world, Solomon strayed and worshiped their false Gods. So God took his kingdom (and his blessings) away from him.
1 Kings 11: 4 For when Solomon was old, his wives turned his heart away after other gods; and his heart was not wholly devoted to the Lord his God, as the heart of David his father had been.
1 Kings 11:9 Now the Lord was angry with Solomon because his heart was turned away from the Lord, the God of Israel, who had appeared to him twice,
1 Kings 11:10 and had commanded him concerning this thing, that he should not go after other gods; but he did not observe what the Lord had commanded.
1 Kings 11:11 So the Lord said to Solomon, “Because you have done this, and you have not kept My covenant and My statutes, which I have commanded you, I will surely tear the kingdom from you, and will give it to your servant.
However, near the end of Solomon's life, he wrote the book of Ecclesiastes. And at its conclusion, we find Solomon returning to the Lord, recognizing that He had drifted away from God and would be judged accordingly.
Eccl. 12: 13 The conclusion, when all has been heard, is: fear God and keep His commandments, because this applies to every person.
Eccl. 12:14 For God will bring every act to judgment, everything which is hidden, whether it is good or evil.
So since the condition for salvation has always been the same – by faith in the promises of God – that condition was not taken away upon Solomon's act of sinning.