Evidently this word from the Lord came to Solomon during temple construction. Note that this was a conditional promise based on obedience to the Mosaic Covenant. God would establish Solomon's kingdom forever (i.e., it would remain in tact; 2 Sam. 7:13). He would also continue to dwell among the Israelites and not forsake them. Unfortunately because Solomon did not continue to obey the covenant completely God divided his kingdom. Because the nation forsook the covenant God ceased to dwell among the people and forsook them temporarily to captivity (cf. Matt. 28:20).
"Throughout the Solomon stories the author presents an activity, then waits until later to state God's approval or disapproval of it. For example, 3:1-15 expresses approval of Solomon's rise to power in chaps. 1-2, and 5:12 explains that the decisions in 5:1-7 demonstrate God-given wisdom. This strategy continues here, where, through some unspecified manner, Solomon receives God's word about the temple."67
The writer evidently inserted this section of text (vv. 11-13) in his description of Solomon's building activities to emphasize the centrality of obedience to the overall success of the project.