A Castle of Bone by Penelope Farmer
Hugh's father buys him a cupboard to put his clothes in. That is one thing he can't do, as it turns out, because this cupboard changes things - sometimes dangerously. The author also wrote "Charlotte Sometimes" and "The Summer Birds", which was short-listed for the Carnegie Medal.