The answer to this question is essentially the contents of the Chinese Remainder Theorem.
If $\gcd(P_1,P_2)=1$, then things work out nicely and there is always such an $n$.
The solution is also unique mod $P_1P_2$, so the smallest integer $n\geq 0$ can be found by taking any solution and taking the representative $0\leq n < P_1P_2$.
As far as finding such an $n$, there isn't a closed form formula, but one particularly nice way is to use Bezout's identity.
This says that for any integers $a,b$, there exist other integers $x,y$ such that $ax+by=\gcd(x,y)$.
These can be computed pretty quickly using the extended Euclidean algorithm.
Applying it to $P_1,P_2$, there exist integers $k_1,k_2$ such that
$$
P_1k_1+P_2k_2=1.
$$
Then the $n$ given by
$$
n = o_1 P_2k_2 + o_2 P_1k_1
$$
satisfies the two congruences.
This isn't quite closed form, but it's probably as close as you can get.
(This and a few other methods for finding solutions are on the Wikipedia page.)
If $\gcd(P_1,P_2)\neq 1$, however, then solutions only exist if
$$
o_1 \equiv o_2 \mod \gcd(P_1,P_2).
$$
To see this, observe if we have a solution $n$, then there are integers $m_1,m_2$ such that
$$
n=o_1+P_1m_1 = o_2+P_2m_2,
$$
and then we reduce mod $\gcd(P_1,P_2)$, which gives the above equation.
When a solution exists in this case, a solution will be
$$
n
=
\frac{o_1 P_2k_2 + o_2 P_1k_1}{\gcd(P_1,P_2)}
$$
where $P_1k_1+P_2k_2=\gcd(P_1,P_2)$, and which will be unique mod $\mathrm{lcm}(P_1,P_2)$.