It's like in German. Normally the last element in the compound is the (grammatical) head. So, foran-hēafde should be the dative singular of the neuter noun foran-hēafod. as dictated by "hēafod". There may well be some exceptions (compare the genders of German Gegenteil and Anteil), but I don't know much in details about this.
That isn't an exception. There is das Teil and der Teil with complementary meanings: das Teil is an individual piece of a group of distinct objects and der Teil is a part of a whole. So, e.g. a spare part is das Ersatzteil and the front part of your house is der Vorderteil. And that is also the reason why it is das Gegenteil and der Anteil.