Consider a system whose Lagrangian is
$$L = \frac12 \mu\left( \dot r^2 + r^2 \dot\theta^2 \right) -U(r) $$
By the Euler-Lagrange equation,
$$\frac{\partial L}{\partial\theta}=\frac{d}{dt}\frac{\partial L}{\partial\dot\theta}$$
Calculating the conjugate potential for $\theta$
$$p_\theta = \frac{\partial L}{\partial\dot\theta} = \mu r^2\dot\theta \equiv l$$
$$\frac{dl}{dt} = \frac{\partial L}{\partial\theta} = 0$$
Also,
$$\frac{\partial L}{\partial r}=\frac{d}{dt}\frac{\partial L}{\partial\dot r}$$
$$\mu r\dot\theta^2-U'(r) = \frac{l^2}{\mu r^3}-U'(r)=\mu\ddot r$$
Note that we cannot substitute with $l$ first, and then differentiate considering $l$ as a constant. All we know is $dl/dt=0$
$$\frac{d}{dr}\left(\frac12\mu r^2\dot\theta^2\right)=\mu r\dot\theta^2=\frac{l^2}{\mu r^3}~~~(1)$$
$$\frac{d}{dr}\left(\frac12l\dot\theta\right)=0~~~(2, \times)$$
$$\frac{d}{dr}\left(\frac{l^2}{2\mu r^2}\right)=-\frac{l^2}{\mu r^3}~~~(3, \times)$$
In the books I've checked, the centrifugal potential energy is defined as
$$U_{cf} = \frac{l^2}{2\mu r^2}$$
and the centrifugal Force is calculated as
$$F_{cf} = -\frac{d}{dr}\left(\frac{l^2}{2\mu r^2}\right)=\frac{l^2}{\mu r^3}$$
This is the point where I'm confused. $l$ is considered as an actual constant when calculating $F_{cf}$. In (2) and (3), considering $l$ as a constant gave bogus results.
Some books write
$$-\frac{d}{dr}\left(\frac{l^2}{2\mu r^2}+U(r)\right)= \frac{l^2}{\mu r^3}-U'(r)=\mu\ddot r$$
and again, $l$ is regarded as an actual constant.
Differentiating as in (1) will result in an opposite sign for the centrifugal part.
Why is $l$ treated differently depending on which context?