Leave a space of approximately 5 feet between the walls of your house and the holes you dig for the fence posts. This will ensure that the foundations remain undisturbed by the digging or the weight of the fence. Maintain the same distance from the foundation all the way down to the base of the fencepost holes.
After digging the post holes, compact the soil in the base of the holes using a 4-inch by 4-inch wooden post before adding gravel and pouring the concrete in around the post. This will help to prevent air holes and gaps, which can lead to the shifting of the backfill to fill them.
If water from rain or garden sprinklers is able to enter the base of the fence posts, it can cause soil erosion. Even if you dig the fencepost holes 5 feet away from the foundation, this erosion could cause the backfill around the foundations to shift, damaging the foundations'integrity. Install a drainage system to carry groundwater and runoff away from the foundations and the footings as soon as it enters.
To maintain the condition of your foundations after digging holes to build a fence close to the house, create a runoff slope to carry surface water away from the house. The slope should be at least five percent for the first 5 feet around the house, reducing to one percent from there on. Plant ground cover that needs minimal water to reduce slope erosion and maintenance.