'To the head teacher's office'
One way to obtain the Welsh equivalent of this type of English phrase is to:
1) put the English phrase the long way round:
to the head teacher's office > to the office of the head teacher
2) get rid of the first 'the' and the 'of' in the phrase:
to the office of the head teacher
to office the head teacher > i swyddfa'r pennaeth
Remember that the preposition i causes a soft mutation. Also y and 'r will cause a soft mutation if it is followed by a feminine singular noun, e.g.
to the middle of the bridge > i ganol y bont