Firstly, make sure it’s facing a direction where it’s not going to bear the brunt of wind, rain or strong sunshine – facing between north and south-east is usually best, though there’s some flexibility here if it’s in a sheltered corner of the garden/house. Tilt the box forward slightly so any rain will run off the top, and a nestbox with some small holes for drainage in the bottom are preferable too – just in case.
After that, somewhere with some surrounding vegetation (ivy, brambles, shrubs, trees) is ideal, but make sure the birds have a clear flight path to access the nestbox hole. For Starlings and House Sparrows (and occasionally other species), boxes placed under the eaves of your house or shed should work well.
Lastly – don’t put your nestbox beside where you feed your birds as any birds looking to nest will waste a lot of energy trying to fend off intruders into their territory!