The writer uses this question to express that God would know if they worshiped another god. Alternate translation: "God would certainly find out" (See: [[rc://en/ta/man/translate/figs-rquestion]])
Here the word "heart" refers to the mind and thoughts. Alternate translation: "he knows what a person secretly thinks" (See: [[rc://en/ta/man/translate/figs-metonymy]])