There's no single distance that applies everywhere. How close a retaining wall can sit to a property line depends first on the local zoning setback rules for the property, and separately on how much room the wall's footing and drainage system actually need behind and around it to work correctly. A wall can technically meet a zoning setback and still cause problems if it's built too close to the line to properly compact backfill or install drainage.
Setback rules are set locally and vary by jurisdiction, and some localities treat retaining walls differently than they treat buildings or fences, sometimes allowing them closer to the line, sometimes not. That's a legal question that has to be checked against the specific property, not assumed from a general rule of thumb.
Separate from the legal setback is a practical one: a retaining wall needs working room behind its face for the footing excavation, compacted backfill, and drainage stone, and a wall with any batter, meaning it leans back slightly into the hillside as it rises, takes up more space below grade than its visible footprint suggests. Building right up against a line can mean there isn't room to properly drain and compact the wall without disturbing soil on the neighboring property.
Before we stake out a wall near a property line, we confirm where the surveyed line actually falls, since fences and old markers are often off from the real boundary, and we lay the wall out with enough room behind it to build the footing and drainage the way it needs to be built, not just squeezed to fit.
More on this from Chelo's Brick & Stone.
Chelo's Brick & Stone serves Hillsville, Galax, Wytheville, Fancy Gap, and Independence, VA. Call for a straight answer and a free on-site estimate.