The closest I think you will get to a rule of thumb for playing depth in ping-pong is to move to a depth where you are able to take your opponent's likely return at your preferred height. This basic rule can then be modified for specific situations such as when you are attacking, defending, playing over the table or using big attacking swings away from the table. Over time you will discover the depths where you are the most comfortable for different situations.
But really, it pretty much all boils down to getting to the distance which gives you the best shot at making a good return. So if your opponent is getting you in close and then attacking at you with a hard shot, you need to make sure you step in quickly to play your stroke, and then step out again quickly so that he can't catch you while you're stuck in too close to the table.
I've written some other thoughts about playing depths when I was troubleshooting my problem with hitting two loops in a row on my backhand side - you might find the analysis interesting and useful for your own situation.