Suppose $X$ is a smooth projective variety and $U$ is an open subset whose complement is of codimension two. If a finite group $G$ acts on $U$ does it always extend to $X$ ?
No, it does not always extend. For instance, let $X\subset \mathbb{A}^4\times \mathbb{P}^1$ be the closed subset of points $((x_0,x_1,x_2,x_3),[Y_0,Y_1])\in \mathbb{A}^4\times \mathbb{P}^1$ such that $$x_0x_3x_1x_2 = x_1Y_0x_0Y_1=x_3Y_0x_2Y_1=0.$$ This is smooth of dimension 3 (it is one of the two small resolutions of a threefold $A_1$ singularity). Consider the open subset $U$ where $(x_0,x_1,x_2,x_3)$ is not $(0,0,0,0)$. The projection $$\text{pr}_{\mathbb{A}^4}:U\to \mathbb{A}^4\setminus\{(0,0,0,0)\},$$ defines an isomorphism of $U$ with the (relatively) closed subset $V$ defined by $x_0x_3x_1x_2=0$. In particular, the induced map $$\text{pr}_{\mathbb{P}^1}\circ \text{pr}_{\mathbb{A}^4}^{1}:V\to U \to \mathbb{P}^1,$$ is the unique morphism such that both $x_1Y_0x_0Y_1=0$ and $x_3Y_0x_2Y_1=0$ hold.
The complement of $U$ has codimension $2$. Now let $G=\mathbb{Z}/2\mathbb{Z}$ act on $V$ by $(x_0,x_1,x_2,x_3) \mapsto (x_0,x_2,x_1,x_3)$. Via the isomorphism $U\to V$, this induces an action of $G$ on $U$. There is no way to extend this to an action on all of $X$. Essentially this is because there is no action of $G$ on $\mathbb{P}^1$ such that $\text{pr}_{\mathbb{P}^1}\circ \text{pr}_{\mathbb{A}^4}^{1}$ is $G$equivariant.

3$\begingroup$ Nice! Let me rephrase polyhedrally (as that's how I roll). On the cone over the $ABCD$ square (labeled clockwise), we have a symmetry switching $A\leftrightarrow C$. Now stretch the apex of this pyramid out to an interval (codim 2 in the whole), making the pyramid into a ziggurat. Byebye symmetry. $\endgroup$ – Allen Knutson Sep 17 '13 at 16:38

$\begingroup$ Bother, ziggurats aren't shaped like I thought! Anyway the point is to keep the faces at the same angles, while stretching the square base to a rectangle. $\endgroup$ – Allen Knutson Sep 20 '13 at 11:29