The rule
Read it as a material rule. Drain and sewer pipe that's approved for use under or within a building can go there. Pipe that isn't approved for that use stays out of three places: under the building or structure, within 2 feet of it, and shallower than 1 foot below the surface of the ground.
So the question isn't only depth. It's what the pipe is approved for. Whether a given material is approved for use under or within a building comes from the materials rules in the code and the approval process in Section 301.2, and the inspector has the last word.
Picture a zone: the footprint of the building, a strip 2 feet wide around it, and the top foot of soil. Pipe that's only approved for outdoor use stays out of that zone, or gets swapped for a material that's approved inside it.
On the job
- Check the listing and markings on the pipe before it goes in a trench near the foundation. Pipe that's fine in the yard can be a correction at the building line.
- Measure from the building or structure, and ask the inspector what the city counts as a structure when a patio, wall or addition is close.
- Where a yard line has to come up shallow, check the cover before you backfill. As the code reads, less than 1 foot below the surface is for pipe that's approved for that use.
The inspector and your city's adopted edition have the final word.