Is there a maximum distance from a planet that a moon can orbit? Given a planet that orbits a star, and a moon that orbits that planet, is it possible to define a maximum orbital radius of that moon, beyond which the moon would no longer orbit the planet, but the star instead?
I initially (naively) thought this point would be where the star's gravity outweighed that of the planet:
$$d_\text{max} = d_\mathrm p - d_\mathrm px$$
$$x = \frac{1}{\sqrt{\frac{m_\mathrm p}{m_\mathrm s}}+1}$$
Where:
$d_\text{max} = $ maximum orbital radius of the moon (around the planet), $d_\mathrm p =$ orbital radius of the planet (around the sun), $m_\mathrm p =$  mass of the planet, $m_\mathrm s = $ mass of the star.
But I quickly realised this assumption was wrong (unless my shoddy maths is wrong, which is very possible), because this gives a value of $258\,772\ \mathrm{km}$ using values of the Sun, Moon, and Earth. $125\,627\ \mathrm{km}$ closer to the Earth than the Moon's actual orbital radius (values from Wikipedia).
Is there a maximum orbital distance? How can it be calculated?
 A: What you want to look for is the Hill Sphere. The resultant distance is about 1.5 million km.
A: The concept you're looking for is that of a planet's Hill sphere.  If a planet of mass $m$ is in a roughly circular orbit of radius $a$ about a star of mass $M$, then the radius of this "sphere" is given by
$$
r_H = a \sqrt[3]{\frac{m}{3M}}.
$$
For the Sun-Earth system, this yields $r_H \approx 0.01 \text{ AU}$, or about 1.5 million kilometers.
The calculation given in the Wikipedia article shows how to derive this in terms of rotating reference frames.  But for a qualitative explanation of why your reasoning didn't work, you have to remember that the moon and the planet are not stationary;  both of them are accelerating towards the star.  This means that it's not the entire weight of the moon that matters, but rather the tidal force on the moon as measured in the planet's frame.  This effect, along with the fact that the centripetal force needed for the star to "steal" the planet is a bit less when the moon is between the star and the planet, leads to the expression given above.  
As pointed out by @uhoh in the comments, the L1 and L2 Earth-Sun Lagrange points are precisely this distance from the Earth.  These are precisely the points where the gravitational forces of the Earth and the Sun combine in such a way that an object can orbit the Sun with the same period as the Earth, but at a different radius.  In a rotating reference frame, this means that the influences of the Earth, the Sun, and the centrifugal force are precisely canceling out;  any closer to Earth than that, and the Earth's forces dominate.  Thus, the L1 and L2 Lagrange points are on the boundary of the Hill sphere.
A: There are several different ways of characterizing whether something is "really" in orbit around the sun or Earth. One is asking which gravitational force is larger. As you found, by that standard, the moon primarily orbits around the sun, with its orbit being next to Earth's. Another criteria would be looking at which body's gravitational potential energy dominates: if you wanted to fly a rocket from the moon to outside the solar system, which body's gravity would contribute more to the energy you would need? For that question, the moon is even more clearly in orbit around the sun rather than Earth. But you can also ask at what point would Earth's gravity be so weak that perturbations from the sun would take the moon out of a stable orbit, which gives you the Hill sphere, of which the moon is well within. There are other pairs of bodies, such as Pluto and Charon, for which these different definitions also give different answers.
