Suppose the structure morphism $g: X\to \operatorname{Spec}(A)$ is separated and of finite type, and $f: \operatorname{Spec}(B)\to \operatorname{Spec}(A)$ is faithfully flat; furthermore, assume $A, B, X$ are all Noetherian. Denote $X\times_A B$ as $X_B$ and let $f': X_B\to X$ be the base change of $f$ along $g$, and $g': X_B\to \operatorname{Spec}(B)$ the base change of $g$ along $f$.

By Serre's affineness criterion, it suffices to show that $R^ig_*\mathcal{F}=0$ for $i>0$ and $\mathcal{F}$ an arbitrary quasi-coherent sheaf on $X$.

By flat base change, the morphism $f^*R^ig_*\mathcal{F}\to R^i{g'}_*{f'}^*\mathcal{F}$ is an isomorphism for any quasi-coherent sheaf $\mathcal{F}$ on $X$. As $X_B$ is affine, the right hand side vanishes for $i>0$. Thus $f^*R^ig_*\mathcal{F}=0$; as $f$ is faithfully flat, this implies $R^ig_*\mathcal{F}=0$ as well, as desired.

In fact, we needn't assume $X\to \operatorname{Spec}(A)$ is separated and finite type, as these properties descend through fpqc morphisms. I haven't thought about dropping the Noetherian hypotheses.

Thus we've shown that if $A\to B$ is faithfully flat and everything is Noetherian, affineness descends.

Here's an example to see that some hypothesis on $f$ is necessary. Let $A$ be a local ring and $B$ its residue field. Let $X=\mathbb{P}^1_A\setminus\{x\}$ where $x$ is any closed point of $X$. Then $X_B$ is $\mathbb{A}^1_B$, whereas $X$ is obviously not affine (as its generic fiber is $\mathbb{P}^1$). I don't see an easy example where $f$ is flat but not faithfully flat at the moment (aside from stupid things, e.g. with $\operatorname{Spec}(A)$ disconnected).

I've just noticed that the Stacks Project gives a proof of this claim, avoiding the Noetherian hypotheses and Serre's criterion.