If $f(x)$ is not $O(x)$ as $x\to0$, we can find a sequence $x_k\ne0$ tending monotonically to $0$ such that all the $f(x_k)$ have the same sign and
$$
\lim_{k\to\infty}\left|\frac{f(x_k)}{x_k}\right|=\infty\tag{1}
$$
For $n\gt0$, find $k_n$ so that for $k\ge k_n$, we have $|x_k|\le1/n^2$ and
$$
\left|\frac{f(x_k)}{x_k}\right|\ge n\tag{2}
$$
Let $j_n=\left\lfloor\dfrac{1/n^2}{|x_{k_n}|}\right\rfloor$, then
$$
\frac1{2n^2}\lt\overbrace{|x_{k_n}+x_{k_n}+\dots+x_{k_n}|}^{j_n\text{ terms}}\le\frac1{n^2}\tag{3}
$$
Summing the right inequality of $(3)$ gives
$$
\left|\sum_{n=1}^\infty\ \overbrace{x_{k_n}+x_{k_n}+\dots+x_{k_n}}^{j_n\text{ terms}}\right|
\le\sum_{n=1}^\infty\frac1{n^2}\tag{4}
$$
which converges. However, $(2)$ and the left inequality of $(3)$ say
$$
\left|\sum_{n=1}^\infty\ \overbrace{f(x_{k_n})+f(x_{k_n})+\dots+f(x_{k_n})}^{j_n\text{ terms}}\right|
\ge\sum_{n=1}^\infty\frac1{2n}\tag{5}
$$
which diverges.
Therefore, $f(x)=O(x)$.
A Note On Inequality $(3)$
The first of the equivalent inequalities in $(6)$ follows from the definition of the floor function:
$$
0\le\frac{1/n^2}{|x_{k_n}|}-j_n\lt1\tag{6a}
$$
$$
j_n|x_{k_n}|\color{#C00000}{\le}1/n^2\color{#00A000}{\lt}(j_n+1)|x_{k_n}|\tag{6b}
$$
$$
\frac{j_n}{j_n+1}1/n^2\color{#00A000}{\lt} j_n|x_{k_n}|\color{#C00000}{\le}1/n^2\tag{6c}
$$
and since $j_n\ge1$, $\frac{j_n}{j_n+1}\ge\frac12$, we get
$$
\frac1{2n^2}\lt j_n|x_{k_n}|\le\frac1{n^2}\tag{7}
$$
which is inequality $(3)$.