That depends on your body (skinny? obese? healthy? suffering from lower back pain or some other problem?) and your mattress (in good condition? medium-firm? firm? too firm?). It also depends on the temperature of your bedroom (because memory foam is temperature sensitive). The actual model of the memory foam topper also makes a big difference (because there are different types and grades of memory foam). In other words, there is no such thing as an ideal thickness.
Theoretically, the best way to choose your memory foam mattress topper is to lay one out on top of your mattress and then go to sleep on it. If you go to sleep faster than normal, and you wake up the next morning with fewer aches and pain in your body, then it is the right thickness and softness for you. If not, you will have to look for another one. Will your local bed and mattress shop let you do this – take home a demo set to try? If yes, great. If not …
If your buying circumstances are less than ideal, try choosing a memory foam pad between 2 inches and 3 inches thick. The important point then becomes picking the right density and firmness. Look at the label of your current mattress, assuming it is a foam mattress. The foam density should be printed somewhere. Choose a memory foam topper pad which has a lower density, which means it will be softer than your existing mattress.
A less accurate, i.e. more subjective, method is to do it by feel. How firm is your mattress? When buying a new memory foam topper pad, find one that is softer than that. You could also “cheat.” Put something heavy in a medium-sized bag, then put the bag on top of your current mattress. How deeply does the weighted bag sink down? When you go to buy your foam topper, choose one which lets your bag sink down more than with your mattress.
There are also customers who prefer to buy two thin memory foam toppers with different densities. The denser foam topper goes in the middle, the lighter and softer topper goes on top. In this manner, they end up with a three layered sleeping surface, where the bottom is their ultra firm mattress, then the medium-firm topper, then the soft topper upper-most. Gets rid of all the headache of deciding what is the ideal thickness and ideal density for the memory foam topper. It even has the added bonus that the foam topper that wears out fastest and most often – the soft, upper-most topper – is also the cheapest to replace.