Injectivity is because $X$ is separated. The locus where two morphisms $S \to X$ agree is a closed subscheme and if it contains the generic point, it's everything.
For surjectivity, we can "spread out" the morphism $Spec K \to X$ to a morphism $U \to X$ from an open subset $U \subset S$ and then use the valuative criterion to fill in the finitely many missing point.
Edit: Here are some more details. So spreading it out is the general procedure where if we have an integral ring $R$ with fraction field $K$, a finite type scheme $X$ and a $K$ point of $X$, we can extend it to a $R_{f}$ point because there will only be finitely many denominators. For an easy example, suppose $X = \mathbb A^1$ and $R = \mathbb Z$ and the rational point is $t \to 1/2$. Then, there is an obvious way to think of this as a $\mathbb Z[1/2]$ point.
So given a rational point of $X$, we can extend this to a map from an open subset $U \subset S$ to $X$. Since $S$ is a Dedekind scheme, there are finitely many height one primes in the complement of $U$. Consider the local ring $R_{\mathfrak p}$ at one of these primes which is a DVR.
By the valuative criterion, we can get a $R_{\mathfrak p}$ point of $X$. Again, by spreading out, we can extend this to a map from $V \to X$ for $V$ another open subset of $S$ that contains $\mathfrak p$. On the other hand, the maps from $V \to X$ and $U\to X$ match on their intersection (by the same argument as for injectivity) and so we can extend this to a map $U\cup V \to X$.
Repeating this process for any points still left over, we get a map $S \to X$ that extends our rational map.