Expanding my comment into something that looks more like a rough answer, because you've actually stumbled upon one of the most fundamental questions in algebraic number theory!
If $K$ is an algebraic number field, then its ring of integers $\mathcal{O}_K$ is a Dedekind domain, and it's a standard fact that every ideal in a Dedekind domain is either principal or generated by two elements.
One fundamental question of algebraic number theory is: when can elements of $\mathcal{O}_K$ be written uniquely as a product of prime elements (just like in $\mathcal{O}_{\mathbb{Q}} = \mathbb{Z}$)?
Now, the reason we care about ideals in $\mathcal{O}_K$ in the first place is that they behave like numbers, but more nicely: it turns out that ideals in $\mathcal{O}_K$ can always be written uniquely as a product of prime ideals. And it's not too hard to show from here that uniqueness of prime factorisation for elements happens precisely when all ideals in $\mathcal{O}_K$ are principal. (Very roughly: you can interpret the ideal $(a)$ and the element $a$ as meaning the same thing, but there's no sensible way of interpreting a non-principal ideal $(a,b)$ as a single element.)
In fact, we can construct an object $C_K$, called the ideal class group of $\mathcal{O}_K$ (or of $K$), that tells us how badly $\mathcal{O}_K$ fails to be a principal ideal domain. It's a group, as its name suggests; and every ideal of $\mathcal{O}_K$ is associated to an element of $C_K$ in a way that respects the multiplication (so if $I\lhd \mathcal{O}_K$ is associated to $[I]\in C_K$, and likewise $J$ to $[J]$, then $IJ$ is associated to $[I][J]$, or in other words $[IJ] = [I][J]$), and such that $I$ is principal if and only if $[I]$ is the identity element of $C_K$.
So let's think about your question in this setting.
- If $C_K$ happens to be the trivial group, then all ideals are principal anyway.
- If $C_K$ is non-trivial, then there are non-principal ideals. Let's take a principal ideal $\mathfrak{a}$ and a non-principal ideal $\mathfrak{b}$ (so that $[\mathfrak{a}]$ is the identity element of $C_K$, and $[\mathfrak{b}]$ is not the identity element). Then $[\mathfrak{a}\mathfrak{b}] = [\mathfrak{a}][\mathfrak{b}] = [\mathfrak{b}]$ is a non-identity element, so $\mathfrak{a}\mathfrak{b}$ isn't principal.
- What if $C_K$ is non-trivial, and $\mathfrak{a}$ and $\mathfrak{b}$ are both non-principal? Then we need to know something about $C_K$. For instance, if $|C_K| = 2$, then there's only one non-identity element, and it must be the same as $[\mathfrak{a}]$ and $[\mathfrak{b}]$; and $[\mathfrak{a}\mathfrak{b}] = [\mathfrak{a}]^2 = \mathrm{id}$, so $\mathfrak{a}\mathfrak{b}$ is principal. But if $|C_K| \geq 3$, then we might have $[\mathfrak{a}] = [\mathfrak{b}]^{-1}$ (in which case their product is the identity) or $[\mathfrak{a}] = [\mathfrak{b}]$ (in which case it isn't). Here we need to know more about the ideals themselves.
So, the crucial question is: how do we calculate $C_K$? Or, at least, some information about it - say, the order of the group $|C_K|$, often called the class number of $K$?
The simple answer is: usually, we can't. We've managed to do a lot of simple cases (e.g. here is a list of number fields whose ideal class group is trivial), but for most examples of number fields $K$, this is still a hard open question. Any book on algebraic number theory, at this point, will probably spend several chapters developing basic techniques in this direction, such as the Minkowski bound. Here are some worked examples. I'll leave you to read around.