The general issue is that you cannot plug your equations of motion into the Lagrangian and naively expect to get the same equations of motion back out again. Why not? Let us look at your specific example.
For the usual story we start with
$$ L = \frac12 m (\dot r^2 + r^2\dot\theta^2) - V(r) . $$
We find that the angular momentum, defined by $\ell=m r^2\dot\theta$, is conserved so the equation of motion for the radial coordinate is
$$ m \ddot r - \frac{\ell^2}{m r^3} + \frac{\partial V}{\partial r} = 0. $$
Now, you want to plug $\ell$ back into the Lagrangian. If we do that we have
$$ L = \frac12 m \left( \dot r^2 + \frac{\ell^2}{m^2 r^2} \right) - V(r). $$
Naively, if we calculate the equation of motion from this Lagrangian that we will get the opposite sign for the $\ell^2/m r^3$ term. This is not correct!
Recall that when we call $\ell$ a conserved quantity we mean it is a constant in time, that is $\dot\ell=0$. Explicitly writing out the Euler-Lagrange equations we have
$$ \frac{\mathrm{d}}{\mathrm{d}t}\left[ \left( \frac{\partial L}{\partial\dot r} \right)_{r,\theta,\dot\theta} \right]
- \left( \frac{\partial L}{\partial r} \right)_{\dot r,\theta,\dot\theta} = 0.$$
Here I have included the reminder that when we take partial derivatives we mean that "everything else" is held constant and what that "everything else" is. For the problem at hand note that
$$ \frac{\partial\ell}{\partial r} = \frac{2\ell}{r} \ne 0 $$
so it is not a general constant. Keeping this in mind, we do get the correct equation of motion (as we must).