To address the particularities of this question for number fields, the basic theorem is attributed to Hilbert, Landau and Siegel. First of all, any nonzero sum of squares in a number field has to be totally positive (that is, it is positive in all real embeddings). Hilbert (1902) conjectured that in any number field, a totally positive element is a sum of 4 squares in the number field. This was proved by Landau (1919) for quadratic fields and by Siegel (1921) for all number fields.

This sounds superficially like a direct extension of Lagrange's theorem, but there is a catch: it is about field elements, not algebraic integers as sums of squares of algebraic integers. A totally positive algebraic integer in a number field $K$ need not be a sum of 4 squares of *algebraic integers* in $K$. The Hilbert-Landau-Siegel theorem only says it is a sum of 4 squares of algebraic numbers in $K$.

For instance, in $\mathbf{Q}(i)$ all elements are totally positive in a vacuous sense (no real embeddings), so every element is a sum of four squares. As an example,
$$
i = \left(\frac{1+i}{2}\right)^2 + \left(\frac{1+i}{2}\right)^2.
$$
This shows $i$ is a sum of two squares in $\mathbf{Q}(i)$.
It is impossible to write $i$ as a finite sum of squares in ${\mathbf Z}[i]$ since
$$
(a+bi)^2 = a^2 - b^2 + 2abi
$$
has even imaginary part when $a$ and $b$ are in $\mathbf{Z}$. Thus any finite sum of squares in $\mathbf{Z}[i]$ has even imaginary part, so such a sum can't equal $i$.
Therefore it is false that every totally positive algebraic integer in a number field is a sum of 4 squares (or even any number of squares) of *algebraic integers*.

Here are some further examples:

In $\mathbf{Q}(\sqrt{2})$, $5 + 3\sqrt{2}$ is totally positive since
$5+3\sqrt{2}$ and $5-3\sqrt{2}$ are both positive. So it must be a sum of at most four squares in this field by Hilbert's theorem, and with a little fiddling around you find
$$
5 + 3\sqrt{2} = (1+\sqrt{2})^2 + \left(1 + \frac{1}{\sqrt{2}}\right)^2 + \left(\frac{1}{2}\right)^2 + \left(\frac{1}{2}\right)^2.
$$
It is impossible to write $5 + 3\sqrt{2}$ as a sum of squares in the ring of integers $\mathbf{Z}[\sqrt{2}]$ because of the parity obstruction we saw for $i$ as a sum of squares in $\mathbf{Z}[i]$: the coefficient of $\sqrt{2}$ in $5 + 3\sqrt{2}$ is odd.

In $\mathbf{Q}(\sqrt{2})$, $\sqrt{2}$ is not totally positive (it becomes negative when we replace $\sqrt{2}$ with $-\sqrt{2}$), so it can't be a sum of squares in this field. But in the larger field $\mathbf{Q}(\sqrt{2},i)$, everything is totally positive in a vacuous sense so everything is a sum of at most four squares in this field by the Hilbert-Landau-Siegel theorem. And looking at $\sqrt{2}$ in $\mathbf{Q}(\sqrt{2},i)$, we find
$$
\sqrt{2} = \left(1 + \frac{1}{\sqrt{2}}\right)^2 + i^2 + \left(\frac{i}{\sqrt{2}}\right)^2.
$$

Hilbert made his conjecture on totally positive numbers being sums of four squares as a theorem, in his *Foundations of Geometry*. It is Theorem 42. He says the proof is quite hard, and no proof is included. A copy of the book (in English) is available at the time I write this as http://math.berkeley.edu/~wodzicki/160/Hilbert.pdf. See page 83 of the file (= page 78 of the book).

Siegel's work on this theorem/conjecture was done just before the Hasse-Minkowski theorem was established in all number fields (by Hasse), and the former can be regarded as a special instance of the latter.

Indeed, for nonzero $\alpha$ in a number field $K$, consider the quadratic form $$Q(x_1,x_2,x_3,x_4,x_5) = x_1^2+x_2^2+x_3^2+x_4^2-\alpha{x}_5^2.$$ To say $\alpha$ is a sum of four squares in $K$ is equivalent to saying $Q$ has a nontrivial zero over $K$. (In one direction, if $\alpha$ is a sum of four squares over $K$ then $Q$ has a nontrivial zero over $K$ where $x_5 = 1$. In the other direction, if $Q$ has a nontrivial zero over $K$ where $x_5 \not= 0$ then we can scale and make $x_5 = 1$, thus exhibiting $\alpha$ as a sum of four squares in $K$. If $Q$ has a nontrivial zero over $K$ where $x_5 = 0$ then the sum of four squares quadratic form represents 0 nontrivially over $K$ and thus it is universal over $K$, so it represents $\alpha$ over $K$.) By Hasse-Minkowski, $Q$ represents 0 nontrivially over $K$ if and only if it represents 0 nontrivially over every completion of $K$.

Since any nondegenerate quadratic form in five or more variables over a local field or the complex numbers represents 0 nontrivially, $Q$ represents 0 nontrivially over $K$ if and only it represents 0 nontrivially in every completion of $K$ that is isomorphic to ${\mathbf R}$. The real completions of $K$ arise precisely from embeddings $K \rightarrow {\mathbf R}$. For $t \in {\mathbf R}^\times$, the equation
$x_1^2+x_2^2+x_3^2+x_4^2-t{x}_5^2 =0$ has a nontrivial real solution if and only if $t > 0$, so $Q$ has a nontrivial representation of 0 in every real completion of $K$ if and only if $\alpha$ is positive in every embedding of $K$ into ${\mathbf R}$, which is what it means for $\alpha$ to be totally positive. (Strictly speaking, to be totally positive in a field means being positive in every ordering on the field. The orderings on a *number field* all arise from embeddings of the number field into $\mathbf R$, so being totally positive in a number field is the same as being positive in every real completion.)

Siegel's paper is "Darstellung total positiver Zahlen durch Quadrate, Math. Zeit. 11 (1921), 246--275, and can be found online at http://gdz.sub.uni-goettingen.de/en/dms/loader/img/?PPN=PPN266833020_0011&DMDID=DMDLOG_0022.