Modern foundation construction tends to leave the soil in and around the foundation very dry and compacted, virtually eliminating both moisture and air. The good news is that this type of environment is not at all desirable for tree roots. So in most cases, it is unlikely that roots will grow under or into your foundation when planted correctly.
However, if your foundation shifts or cracks due to freezing and thawing, or if pipes leak or break, or if there is moisture condensation around cement or stone foundations, the conditions can become more attractive to tree roots. Over time, they can slowly wedge themselves in. To prevent encroachment of tree roots, you can have root barriers made of plastic or polyurethane installed to extend the life of cement foundations.
Moreover, tree placement is key! Large trees should never be planted within 30 feet (the dripline of mature tree crowns) of the built structure.