The bell was a later association; the head is a metaphor.
Middle English berfrey could name a siege tower. Tower and shelter uses broadened, and association with bell helped shape belfry. A later figurative use names someone’s head, as in bats in the belfry.