IMDB lists one filming location
Black Hangar Studios, Hampshire, England, UK
However, the Heaven Sent Wikipedia Entry adds
Filming for the Castle interior scenes took place in Cardiff Castle and Caerphilly Castle, in addition to constructed sets
And further links to Rachel Talalay's1 tumblr entry Notes on Heaven Sent which includes the following information
We location-scouted castles: Caerphilly, Cardiff, St Donat’s (William Randolph Hearst’s house/castle in Wales, now a school), Castle Coch, Raglands, and Chepstow. Each had elements that could work, but we used only the first two — St Donat’s was a wish-list addition, but was ultimately difficult to shoot for the complicated scenes we were placing there.
1The director of the episode!