Abarim Publications' online Biblical Hebrew Dictionary
The masculine noun גג (gag) means roof or top, or (as HAW Theological Wordbook of the Old Testament puts it) the highest point of an edifice. Its root is unknown and it has no sibling derivations.
The noun גג (gag) denotes most commonly the flat roof of a building on which things can take place; usually to do with idolatrous worship (Judges 16:27, Joshua 2:6, 2 Samuel 11:2, 2 Kings 23:12, Jeremiah 19:13 and 32:29, Zephaniah 1:5; but also Acts 10:9). Roofs were also used to publish messages, news or expressions of grief into the neighborhood (Isaiah 15:3, Matthew 10:27, Luke 12:3), and possibly as a place of refuge (Joshua 2:6, Isaiah 22:1, Matthew 24:17) or lodging (1 Samuel 9:25-26, 2 Samuel 16:22).
The housetop seems to indicate a certain spiritual exposure. Someone on the housetop opens himself for something, preferable something soothing, or higher. Note that the ominous names Gog and Magog are derived from this root.