This is true if and only if the complement of $U$ has codimension at least $2$. 
To see that this condition is sufficient see [this MO answer][1].
To see that it is necessary, see Sasha's [example](https://mathoverflow.net/a/114039), or take any $X$ and any Cartier divisor $D$ on $X$ and note that for $U=X\setminus \operatorname{Supp}D$, $i^*\mathscr O_X(mD)\simeq \mathscr O_U\simeq i^*\mathscr O_X(nD)$ for any $m,n\in \mathbb Z$, so $i_*i^*F$ can't be $F$ for both choices.

*Remark* for the codimension $2$ condition, you don't actually need smoothness. See the linked answer for more.


  [1]: https://mathoverflow.net/questions/45347/why-does-the-s2-property-of-a-ring-correspond-to-the-hartogs-phenomenon/45354#45354