The answer to the question in the title is "yes". This is proved for example here, or here (page 5).
However, I seem to be able to construct a counterexample. Can you help me find the flaw in my argument?
Let $E$ be an elliptic curve, say over $\mathbb C$. Then $E-\{0\}$ is the spectrum of a Dedekind domain $R$, and has class group isomorphic to $E(\mathbb C)$. (Because $\mathrm{Cl}(E)=E(\mathbb C)\times \mathbb Z$, and $\mathrm{Cl}(E-\{0\})$ is the quotient of $\mathrm{Cl}(E)$ by the cyclic subgroup generated by $[0]$.) Now the class group of $\mathrm{Spec}(R)$ is just the ideal class group of $R$. Take a non-torsion point of $E$, considered as a prime ideal $\mathfrak{p}$ of $R$. I claim that $S:=\mathrm{Spec} (R)-\{\mathfrak{p}\}$ is not affine.
Let $T=\Gamma (S,\mathcal O_S)=\{ {{a}\over{b}}\in Q(R) |b\notin \mathfrak{q}\in \mathrm{Spec}(R),\mathfrak{q}\neq \mathfrak{p}\}$. I will show that $T=R$. It suffices to show that every element $x\in \mathfrak {p}$ is also contained in some other prime ideal than $\mathfrak p$. Were it not so, then the principal ideal $(x)$ would be equal to $\mathfrak{p}^n$ for some $n$, by the unique prime decomposition of ideals in Dedekind domains. But the image of $\mathfrak{p}$ in the ideal class group is a non-torsion element, so no power of $\mathfrak{p}$ can be a principal ideal. Therefore $T=R$, and $S\neq\mathrm{Spec}(R)=\mathrm{Spec}(T)$, and hence $S$ is not affine.
($S$ and $\mathrm{Spec}(R)$ really are nonisomorphic, because for instance they have different etale fundamental groups)