How close is too close, when digging below foundation level?
It would depend on soil type and the load on the foundation. As a very rough rule of thumb, the soil actively supporting a foundation spreads at a 45 degree angle downwards from the outer lower edges of the foundation. You should be able to dig outside this section with impunity. If you encroach upon it, if you only excavate something like 15 foot sections at a time, assuming the wall is longer than this, you shouldn't encounter any issues unless the foundation is extremely heavily loaded, such as supporting a large concentrated load.

When backfilling, be sure the soil within the support prism is very well compacted, but be careful not to collapse the pipe.