Can be used ParametricNDSolveValue
F = 1.2;
sol = ParametricNDSolveValue[{f'[
x] (1 + 20 f[x] (1 - f[x]) f[x]^2) == -f[x], f[0] == a},
f, {x, 0, 5}, {a}];
M[a_?NumericQ] := (NIntegrate[sol[a][x], {x, 0, 5}] - F)^2
sol1 = NMinimize[{M[a], 0 < a < 1}, a]
(*{1.03015*10^-21, {a -> 0.69524}}*)