To change the setting, go to your Castle, click on the overview tab, and click the radio button labeled "Hide troops in sanctuary"
Hiding troops in santuary will not stop your Wall and Field Defences from defending.
NOTE: Troops sent by your alliance or from your other cities to reinforce your city are automatically set to defend, even if you have your own troops hidden in sanctuary. By reinforcing one of your cities with troops from another, you can have some troops defending without setting your city's entire army to defend. This may be appropriate to discourage farming attacks if you've been repeatedly attacked by small armies, without risking losing all of your city's troops.