1) Obviously if $X$ is not affine, then $U=X$ is an open subset which is not affine (see Kevin's comment above) but this might feel cheating.

2) A more general example along the lines of Robin's example is the following:

Let $X$ be an arbitrary $S_2$ affine scheme of dimension at least $2$. (If you don't know what $S_2$ is, take *normal*, or *smooth*). Let $Z\subset X$ be a closed subscheme of codimension at least $2$. Then $U=X\setminus Z\subset X$ is a proper open subset which is affine.

Here is why it's not affine: Assume that $X={\rm Spec} A$ is affine and let $\iota:U\hookrightarrow X$ be the natural embedding. By the $S_2$ property it follows that $\iota_*\mathcal O_U\simeq \mathcal O_X$, or equivalently the induced morphism on global sections $\Gamma(U, \mathcal O_U)\to A$ is an isomorphism, but then if $U$ were affine, then this would imply that $\iota$ is an isomorphism, which is not true by construction.