I will only consider the case of connected projective (this is not really necessary) curves $X, C, D$. over an algebraically closed field $k$. The canonical injection $O_X\to O_C\times O_D$ induces an exact sequence of sheaves on $X$
$$ 1 \to O_X^* \to O_C^* \times O_D^* \to F \to 1 $$
where $F$ is a skyscrapper sheaf supported at the intersection points of $C$ and $D$. Passing to cohomology,
we get
$$ 1 \to k^* \to k^* \times k^* \to F(X) \to \mathrm{Pic}(X)\to \mathrm{Pic}(C) \times \mathrm{Pic}(D)\to H^1(X, F)=0.$$
When $C, D$ intersect transversally at a single point (ordinary double point), a local computation shows that $k^* \times k^*\to F(X)$ is surjective, and you get your isomorphism.

As Steven said, this really depends on how $C$ and $D$ intersect (in fact, when $C$ and $D$ are smooth, your isomorphism implies that $C$ and $D$ intersect transversally at a single point; non transversal intersection point can give additive subgroup in $\mathrm{Pic}(X)$ and more transversally intersection points give subtori in $\mathrm{Pic}(X)$). Also in higher dimension $H^1(X, F)$ may not vanish, and the above methode does not work.

The general picture for proper curves can be found in Bosch, Lütkebohmert and Raynaud, Néron Models, Chap. 9., §2. They make a ''dévissage'' of $\mathrm{Pic}^0(X)$.

[**EDIT**] Let me rewrite Sándor's nice interpretation in cohomological terms. It will make explicit the sheaf $F$ above and gives a better understanding of what is going on, and in any dimension. Denote by $E=C\cap D$ the closed subscheme defined by the ideal $J_C+J_D$. Then we have an exact sequence of sheave on $X$:
$$ 1 \to O_X^* \to O_C^* \times O_D^* \to O^*_{E} \to 1 $$
in the middle, the map is $(a, b)\mapsto a|_E (b|_E)^{-1}$. The exactness is checked locally. Passing to cohomology, we get
$$ O(C)^\star\times O(D)^\star\to O(E)^* \to \mathrm{Pic}(X) \to \mathrm{Pic}(C)\times \mathrm{Pic}(D)\to \mathrm{Pic}(E)$$
and the last map is $(L, H)\mapsto L_{|E}\otimes (H_{|E})^{-1}$, therefore the exact sequence becomes

$$ O(C)^\star\times O(D)^\star\to O(E)^\star \to \mathrm{Pic}(X) \to \mathrm{Pic}(C)\times_{\mathrm{Pic}(E)} \mathrm{Pic}(D)\to 1.$$
So Sándor's map $\mathrm{Pic}(X) \to \mathrm{Pic}(C)\times_{\mathrm{Pic}(E)} \mathrm{Pic}(D)$ is always surjective. It is injective if and only if $O(C)^\star\times O(D)^\star\to O(E)^\star$ is surjective. This is not always the case (consider two irreducible curves meeting at more than one point or meeting at a single point but not transversally which implies that $E$ is a non-reduced point), but is true if for instance $O(E)=k$ (e.g. $E$ is geometrically connected, geometrically reduced **and proper**).

[**EDIT 2**] Of course, in all this answer, $X$ is supposed to be **reduced**. Otherwise $O_X\to O_C\times O_D$ (and that one with invertible functions) would not be necessarily injective. If $X$ is not reduced, there is a dévissage from $\mathrm{Pic}(X)$ to $\mathrm{Pic}(X_{\mathrm{red}})$ in Bosch & al, *op. cit.*