How deep does a deck post footing need to be if it’s directly behind a retaining wall?
Comment by @BillDOe is correct: it should go the required depth for the post, measured from the base of the retaining wall as if there was no wall and no retained earth there. As long as it has sufficient depth, it can be arbitrarily close to the face of the retaining wall.
You don't mention if you are planning/required to pour a footing for the post. That may change this answer as the presence of the wall may have an impact of the options you have for the design of the footing and the resulting distance from the existing wall.
If you have some flexibility and can set the post further back from the wall, your local code might have a minimum distance defined at which you can set the post at the standard depth, without accounting for the wall. Somewhere between 1' or 2' is pretty common. Some require specific types of retention systems to prevent the wall from toppling from the top during high winds.
Another factor to keep in mind is frost heave: if the frost line is 4' in your area, that means 4' in a flat, uninterrupted section of land. If you are directly behind a 3' wall and only go 4' from the top of the wall, it's very likely that the post will experience freeze/thaw cycles during winter. That would be bad for the deck, and could also be a problem for the wall itself.
One last thing to watch out for is any kind of engineering fabric or mesh extending back from the face of the wall, and a few inches deep in the soil. If it's there, you would need to carefully cut through it and avoid disturbing it as much as possible. you do NOT want to try and auger through it...
As always, your best bet is to check with your building inspector, but this is the typical recommendation. Different municipalities have different requirements.