Magnitude of vector quantities The gravitational force in the vector form is defined as $$ \vec{F}=-\frac{GMm}{\boldsymbol {r^3}}\vec{r}$$
Many textbooks define its magnitude as $$F_g=-\frac{GMm}{r^2}$$
However, in the derivation of the gravitational potential energy $U_g=-\frac{GMm}{r}$ $$W_\text{by gravity}=\int_c \vec{F}_\text{grav} \cdot \mbox{d} \vec{r}=\int_{r1}^{r2} F\ \mbox{d}r \cos(180^{\circ})=-\int_{r1}^{r2} F\ \mbox{d}r$$
$$=-\int_{r1}^{r2} \frac{GMm}{r^2}\ \mbox{d}r=+\frac{GMm}{r}\Biggr|^{r_2}_{r_1}=\frac{GMm}{r_2}-\frac{GMm}{r_1}$$
where $r_2>r_1$
since $\Delta U_g=-W_{by.grav}$
$$\Delta U_g=U_2-U_1=GMm \Big(\frac{1}{r_1}-\frac{1}{r_2}\Big)$$
setting $r_2=\infty$, $U_2=0$
$$-U_1=GMm\frac{1}{r_1}$$
Therefore $$U=-\frac{GMm}{r}$$
which implies that the correct way of writing the magnitude should be $F=\frac{GMm}{r^2}$ (i.e. no minus sign) since the direction has already been taken into account(by cos(180)) during the dot product operation.
So should I always use the expression of the magnitude without the negative sign because the direction of the force is only to be considered "later" in a sense that the negative sign should not be part of the magnitude?
I'm having the same trouble when dealing with the force exerted by a spring in Hooke's Law, e.g. in the derivation of the EPE:
$$W_s=\int \vec{F}_s\ \cdot \mbox{d}\vec{x}=\int_{x_1}^{x2}kx\ \mbox{d}x \cos(180^{\circ})=-\int_{x_1}^{x2}kx\ \mbox{d}x$$
Using $\Delta U_s=-W_s$ will yield $U_s=\frac{1}{2}kx^2$, which again implies that $F_s=kx$ (rather than $F_s=-kx$)
But in other derivations like the effective spring constant of a certain combination, $F_s=-kx$ is used instead.
 A: The formula
$$F_G = - G \frac{M m}{r^2}$$
is correct. The minus sign represents the fact that the gravitational force is attractive.
There is a small mistake in your calculation of $W_G$, when you substitute $F_G$ with its formula. The formula for $F_G$ contains a minus sign that should have cancelled the minus before the integral:
$$- \int_{r_1}^{r_2} F \ \mbox{d}r = \int_{r_1}^{r_2} G \frac{M m}{r^2} \ \mbox{d}r$$
I also suppose that, since you used $\cos(180°)$, you are considering the case where $r_2$ > $r_1$.
From this you derive that
$$W_G = GMm \left( \frac{1}{r_1} - \frac{1}{r_2} \right)$$
and this is indeed positive, because you need energy to separate two objects that are attracting each other.
For a conservative force, such as the gravitational force or the elastic force, work is also defined as $W = - \Delta U$, where $Delta U$ is the change in potential energy. Notice the minus sign here. There is a reason for it. Work, as I said above, is the energy needed to go from one place to another. It's positive when you need to give energy and negative when you obtain energy (usually kinetic energy). The potential on the other hand has a different interpretation, it's one component of the energy possessed by an object.
Since we are usually interested in the difference in potential energy, and not its absolute value, we have a certain freedom to choose when the potential energy is 0. Usually for the gravitational case 0 is chosen as the potential energy at infinite distance, while for the elastic case it's at the rest position ($x = 0$).
So if
$$W_G = G \frac{M m}{r_1} - G \frac{M m}{r_2}$$
and
$$W_G = - \Delta U = U(r_1) - U(r_2)$$
we obtain that
$$U(r) = - G \frac{M m}{r}$$
No need to change the sign of $F$. And the same principle applies to the elastic case.
A: I would not provide the whole derivation for the expression of potential energy of a system but I would like to give you the correct reasoning for the signs which have to be taken into consideration while deriving the expressions of potential energy.please consider the definition below which may help you:-
The change in potential energy of a system is defined as the negative of work done by the internal conservative forces of the system.
The negative sign will effect some equations you posted.
A: 
So should I always use the expression of the magnitude without the negative sign because the direction of the force is only to be considered "later" in a sense that the negative sign should not be part of the magnitude?

The answer is yes, you just remember magnitude without negative sign as negative just suggest direction and says it is attractive force. So in whole physics to understand easily never put negative in front of magnitudes as they just suggest direction only.
