When should we using moving average in algorithm design?
So when will you think you need moving average in an algorithm design? 


If you mean moving average filters; moving averages as the name suggest are computed as averages of samples say,  $M-1$ previous samples (+ current sample) from input $x[n]$ to get an average output $y[n]$, repeating the process to get all $y$ samples. Computing their mean to get an averaged $y[n]$ signal. What you get is a smoothing effect.

As explained by Sanjit Mitra in the chapter on Discrete-Time Systems in his book. When your data is corrupted with noise and you happen to have multiple measurements of the same data samples, a good estimation of your signal is doing the ensemble average. But if you only have one set of measurement, then moving averages is a way of doing it. The result is a smoothing of your noisy signal. An M-point moving average is defined as a FIR system as:

$$ 
y[n] = \frac{1}{M}\sum_{k=0}^{M-1} x[n-k],\quad 0\leq n-k \leq M-1
$$


  And if we need one, how we should select the weight?


As seen in the equation, all the weights are equal and dependent on the length of the chosen filter:

$$
h[n] = \frac{1}{M}
$$

The choice of the length is critical. An efficient implementation however is done by introducing a recursive form and requires only 2 additions and 1 division. 

Again, depending on your application, there are other variants  of the moving average that may be more suited to your signals.