First notice that $j: U\to S$ is affine if and only if $U\to X\times_S X$ is affine (to check this, one can suppose $S$ is affine, then use the facts that $X\times_S X$ is affine and $U$ is open in $X\times_S X$).
So we are reduced to see whether $U$ is an affine scheme when $S$, and hence $X$ are affine. It is well known that then the complementary $\Delta(X)$ of $U$ in $X\times_S X$ is purely 1-codimensional. This is true essentially only when $X\to S$ has relative dimension $1$ (for reasonable schemes). In particular, if $X$ is any algebraic variety of dimension $d>1$, then $U$ can't be affine.
Claim: Let $C$ be a smooth projective geometrically connected curve of genus $g$ over a field $k$, let $X\subset C$ be the complementary of $r$ points with $r+1-g >0$. Then $U$ is affine.
Proof. We can suppose $k$ is algebraically closed (the affiness can be checked over any field extension). Let $D$ be the divisor $D=C\setminus X$ and $H=D\times C+C\times D + \Delta(C).$ Then $U=C\times C\setminus H$. It is enough to show that $H$ is an ample divisor on the smooth projective surface $C\times C$. To do this, we will use Nakai-Moishezon criterion (see Hartshorne, Theorem V.1.10).
It is easy to see that $(D\times C)^2=0$ (because $D \sim D'$ with the support of $D'$ disjoint from that of $D$), $(D\times C).(C\times D)=r^2$, $(D\times C).\Delta(C)=r$, and $\Delta(C)^2=\deg O_{C\times C}(\Delta(C))|_{\Delta(C)}=\deg \Omega_{C/k}^{-1}=2-2g.$ Thus $H^2=2(r^2+r+1-g)>0$.
Let $\Gamma$ be an irreducible curve on $C\times C$. If $\Gamma\ne \Delta(C)$, it is easy to see that $H.\Gamma>0$. On the other hand, $H.\Delta(C)=2r+2-2g=2(r+1-g)>0$ and we are done.
I didn't check the details because it is time to sleep, but I believe the proof is essentially correct.
EDIT
(1). In the above claim, we can remove the condition $r+1-g>0$:
Let $C$ be a smooth projective connected curve over a field $k$, let $X$ be an affine open subset of $C$. Then $U$ is affine.
The proof is the same as above, but consider $H=n (D\times C+ C\times D)+\Delta(C)$ for $n > g-1$. The same proof shows that $H$ is ample.
(2). Let $S$ be noetherian, and let $C\to S$ be a smooth projective morphism with one dimensional connected fibers, let $D$ be a closed subset of $C$ finite surjective over $S$. Let $X=C\setminus D$. Then $U$ is affine.
Proof. One can see that $D$ is a relative Cartier divisor on $C$ (because $D_s$ is a Cartier divisor for all $s\in S$). So the $H$ defined as above is a relative Cartier divisor on $C\times_S C$. We showed that $H_s$ is ample for all $s$. This implies that $H$ is relatively ample for $C\times_S C\to S$ (EGV III.4.7.1). So $U$ is affine.