To find out that answer, you have to determine what the root spread of the tree will be when mature. On average, tree roots will be 1/3 wider than the crown (leaf area) of the tree. But species of trees vary, so make sure you know.
When listing the root spread, or crown spread — it’s the full width that’s listed. You don’t want any more than the smallest, farthest roots to touch the foundation of your house.
So, say you only have 40 feet of yard between your foundation and the neighbor’s fence.
That means you’ll want a tree with a 40 foot root spread or less, and you’ll need to plant it 20 feet from the house if it’s 40 feet wide. (In other words, divide the mature size in half to know where the tree center - trunk - will be.)
Keep in mind the crown spread as well. Branches overhanging your roof, the neighbor’s yard or your cars will drop limbs, as that’s what trees do, just like we lose hair and replace it.