Suppose $m\le n$, then we have $S_n-S_m = \sum_{k=m+1}^n a_k \phi_k$.
Then $(S_n(x)-S_m(x))^2 = \sum_{k_1=m+1}^n \sum_{k_2=m+1}^n a_{k_1} a_{k_2} \phi_{k_1}(x) \phi_{k_2}(x)$.
Since the $\phi_k$ are orthonormal, we have
$\int_a^b \phi_{k_1}(x) \phi_{k_2}(x) dx = \delta_{k_1 k_2}$, which gives
$\int_a^b ((S_n(x)-S_m(x))^2 dx = \sum_{k=m+1}^n a_k^2$.
If we can show that the $a_k$ are square summable then the desired result follows.
Since $f$ is Riemann integrable, we have that $f^2$ is also Riemann integrable
(this result is not immediate) and Bessel's inequality gives
$0 \le \int_a^b |f(x) -S_n(x)|^2 dx = \int_a^b f(x)^2 dx - \sum_{k=1}^n a_k^2$,
from which we conclude that th $a_k$ are square summable.
Aside: To see that $f^2 $ is integrable, look at The product of two Riemann integrable functions is integrable for example.