And they have built the high places of Tophet, which is in the Valley of the Son of Hinnom, to burn their sons and their daughters in the fire, which I did not command, nor did it come into My heart.
(Jer 7:31)

(they have also built the high places of Baal, to burn their sons with fire for burnt offerings to Baal, which I did not command or speak, nor did it come into My mind),
(Jer 19:5)

And they built the high places of Baal which are in the Valley of the Son of Hinnom, to cause their sons and their daughters to pass through the fire to Molech, which I did not command them, nor did it come into My mind that they should do this abomination, to cause Judah to sin.’
(Jer 32:35)

Above are three examples where God is recorded as saying either, “nor did it come into My heart” or “nor did it come into My mind”. The question that immediately arises is – what did God mean when He said these things? If you approach these texts with an open theist posture you might be inclined to say that God was saying that He hadn’t even conceived the possibility of these things happening. That could be your explanation of the phrase, “nor did it come into My mind”; a kind of equivalent of God saying, “The things that these people are doing… I hadn’t even imagined this sort of thing happening. It’s not only outlandish, it’s unexpected.”

Leaving aside the texts that assert God’s foreknowledge of future events referenced in prior teachings (Ps 139:4; Ps 139:16; Ps 147:5; 1 Sam 8:11-18; Is 40:28; Is 46:10; Is 48:8; Mt 20:18; Mt 26:34; Lk 17:22; Jn 13: 18-30; Jn 21:18-19; Jd 14-15; 2 Tim 1:9;  1 Jn 3:20;  etc.], we will simply look at these verses and see why they are not intended to teach that God was unaware of the reality that these heinous sins would occur.

First, consider the context. God was describing the sin of His people in committing the atrocity of sacrificing their sons and daughters in the fire. Each time, in the citations above, He distanced Himself from such a practice by first saying that He never commanded them to do it; and then, as though to accentuate the point, He said that it never entered into His heart or mind. The context does not suggest “shock” as though God did not see these abominable acts coming; the context suggests a crescendo of disgust and ‘distancing’. So, I don’t think we should interpret these verses by reading into them an assertion of divine ignorance; rather, the natural reading suggests that God is using an anthropomorphism to accentuate the ungodly nature of what the people were doing.

Second, literally speaking, God had thought of these things before which is why He forbade the people of Israel from such behavior in Leviticus (18:21) and Deuteronomy (18:10).