If I understand the question correctly, you're asking about the height $H$ above the surface of the planet where you can just barely see the moon on the horizon, as in this diagram where I've greatly exaggerated the radius $R$ of the planet compared to the distance $a$ to the moon (of negligible size).
In this diagram all three triangles are similar right triangles. Using the inverse Pythagorean theorem,$$\frac{1}{(H + R)^2} + \frac{1}{a^2} = \frac{1}{R^2}, $$which we can rearrange to give (try it yourself before revealing)