Since the problem is local around $p$, you can assume that $Y=\operatorname{Spec}(A)$ where $A$ is a noetherian domain (quasi-projectiveness is irrelevant).
Clearly, every point $\mathfrak q \in \operatorname{Spec}(A)$ of height one is distinct from $p$ (since $\mathfrak q$ it corresponds to a subvariety of codimension $1$). So every function $f$ defined on $operatorname{Spec}(A)\setminus \lbrace p\rbrace $ is defined at $\mathfrak q $.
You can then conclude that $f\in A$, that is $f$ extends regularly through $p$, thanks to the formula valid for a noetherian normal domain (Matsumura, Commutative ring theory, Theorem 11.5, page 81)
$$ A=\bigcap_{ht(\mathfrak q)=1} A_ \mathfrak q $$
A general result in this vein is that if $X$ is a locally noetherian normal integral scheme and $Y\subset X$ a closed subset of codimension $\geq 2$, the restriction morphism $\mathcal O_X(X)\to \mathcal O_X(X\setminus Y)$ is bijective.