Yes, this is true. In particular, we have to use a theorem called the Fundamental Theorem of Algebra which states the following:
Any polynomial of degree $n$ with complex coefficients is the product of $n$ linear factors.
For instance, $ax^2+bx+c$ can always be written as $a(x-k_1)(x-k_2)$ for potentially complex $k_1$ and $k_2$.
Then, we need another piece of machinery to apply this theorem to the real numbers. In particular, we need to know about the complex conjugate defined as follows:
$$\overline{x+iy}=x-iy.$$
You can check that $\overline{a}\cdot\overline{b}=\overline{ab}$ and $\overline{a}+\overline{b}=\overline{a+b}$. Basically, this reflects the complex plane over the real axis, and, in doing so, preserves multiplication and addition. However, for any real number $\overline{x}=x$. We can use this in the following way:
Suppose $f(x)=a_nx^n+a_{n-1}x^{n-1}+\ldots a_1x + a_0$ is a polynomial with real valued coefficient. Then, we can calculate, for any complex number $z$ that:
$$\overline{f(z)}=f(\overline z)$$
which is proven since, for instance $\overline{a_n z^n}=\overline{a_n} \cdot \overline{z^n}=a_n \overline{z}\,\! ^n$ since $a_n$ is real. In particular, this means that, suppose that $a+bi$ is a root of $f$. Then so must $a-bi$ be a root of $f$ - that is, complex roots come in so-called "conjugate pairs".
We can exploit this in the following way: A polynomial $f(x)$ is the product of its leading coefficient, $a_n$, and of the terms $(x-z_i)$ where $z_i$ is a sequence indexing its roots. Now, if $z_i$ is real, then we're fine, because it is a linear factor. The quadratic factors arise because, instead of writing, for a complex root $a+bi$ and its conjugate $a-bi$ the product $(x-a-bi)(x-a+bi)$, involving complex terms, we can multiply the expression out to receive $(x^2 - 2ax + a^2 + b^2)$ which is a quadratic in $x$ with real coefficients. Doing this with all the factors, we see the polynomial is writable as a product of linear and quadratic factors.