show/hide this revision's text 2 added 2 characters in body

For simplicity, put $X_x=\mathrm{Spec}(\mathcal{O}_{X,x})$ and $X'_x=X_x\setminus\{x\}$.

As was pointed out in name's answer, the diagram in the question is not cartesian in general. However, if we replace $\mathrm{Spec}(K)$ by the punctured spectrum $X'_x$, we get $$\begin{array}{ccc} X'_x & \longrightarrow & U\\ \downarrow & & \downarrow\\ X_x & \longrightarrow & X \end{array}$$ which is trivially cartesian (no assumption on $X$ or $x$ here).

If, moreover, you assume that $\{x\}$ is defined by finitely many equations (in some affine neighborhood) then the natural map $X_x\coprod U\to X$ is (faithfully flat and) quasicompact, which by flat descent implies that our diagram is also cocartesian. (This works in particular if $X$ is locally noetherian.)

If it is cocartesian and $X$ is integral, and you work in the category of separated schemes, then your original diagram is also cocartesian, because if two morphisms from $X'_x$ to a separated scheme $Z$ coincide on $\mathrm{Spec}(K)$, they must be equal by density.

Apart from these cases I don't have a general answer. An interesting special case is when $X=\mathrm{Spec} k[(x_n)_{n\in\mathbb{N}}]$ ($k$ a field), and $x$ is the origin. In this case, the natural map $X'_x\coprod U\to X$ is not a topological quotient map! In other words, the above diagram is not cartesian cocartesian as a diagram of topological spaces. However, I could not prove that it is not cocartesian as diagram of schemes.

show/hide this revision's text 1

For simplicity, put $X_x=\mathrm{Spec}(\mathcal{O}_{X,x})$ and $X'_x=X_x\setminus\{x\}$.

As was pointed out in name's answer, the diagram in the question is not cartesian in general. However, if we replace $\mathrm{Spec}(K)$ by the punctured spectrum $X'_x$, we get $$\begin{array}{ccc} X'_x & \longrightarrow & U\\ \downarrow & & \downarrow\\ X_x & \longrightarrow & X \end{array}$$ which is trivially cartesian (no assumption on $X$ or $x$ here).

If, moreover, you assume that $\{x\}$ is defined by finitely many equations (in some affine neighborhood) then the natural map $X_x\coprod U\to X$ is (faithfully flat and) quasicompact, which by flat descent implies that our diagram is also cocartesian. (This works in particular if $X$ is locally noetherian.)

If it is cocartesian and $X$ is integral, and you work in the category of separated schemes, then your original diagram is also cocartesian, because if two morphisms from $X'_x$ to a separated scheme $Z$ coincide on $\mathrm{Spec}(K)$, they must be equal by density.

Apart from these cases I don't have a general answer. An interesting special case is when $X=\mathrm{Spec} k[(x_n)_{n\in\mathbb{N}}]$ ($k$ a field), and $x$ is the origin. In this case, the natural map $X'_x\coprod U\to X$ is not a topological quotient map! In other words, the above diagram is not cartesian as a diagram of topological spaces. However, I could not prove that it is not cocartesian as diagram of schemes.