Let $p$ be a point of $S$ and $v$ a vector based at $p$. The algorithmic solution to your question has two phases: Describe the set $T_{p} S$ of vectors tangent to $S$ at $p$, and project $v$ into $T_{p} S$.
Here's a general sketch (including technical hypotheses that are "almost certainly true in real situations"): Suppose $S$ is defined by $m$ equations in $n > m$ variables; precisely, assume $S$ is a regular level set defined by equations
$$
g_{i}(x_{1}, \dots, x_{n}) = c_{i},\quad i = 1, \dots, m,
$$
in which the function $g_{i}$ have continuous first partial derivatives and the gradient vectors $n_{i} = \nabla g_{i}(p)$ are linearly independent. The tangent space $T_{p}S$ is the set of vectors $x$ satisfying $\langle n_{i}, x\rangle = 0$ for all $i$. This is a homogeneous linear system of $m$ equations in $n$ variables. A basis for the set of solutions can be found by "standard linear algebra techniques" (Gaussian elimination).
Once you have a basis $\{w_{1}, \dots, w_{n-m}\}$ of $T_{p} S$, use the Gram-Schmidt algorithm to construct an orthonormal basis $\{u_{1}, \dots, u_{n-m}\}$ of $T_{p} S$. The desired projection is
$$
\sum_{j=1}^{n-m} \langle v, u_{j}\rangle u_{j}
= \langle v, u_{1}\rangle u_{1} + \dots + \langle v, u_{n-m}\rangle u_{n-m}.
$$
The final formula is essentially trivial to work with; the "hard part" is to calculate an orthonormal basis of $T_{p} S$.
Example: Suppose $S$ is defined by
\begin{align*}
g_{1}(x_{1}, \dots, x_{5})
&= (x_{1} - 1)^{2} + x_{2}^{2} - (x_{3} - 1)^{2} = 0, \\
g_{2}(x_{1}, \dots, x_{5})
&= x_{1} + x_{4} + x_{5} = 0,
\end{align*}
and $p = (0, \dots, 0)$ is the origin. The respective gradients are
\begin{align*}
\nabla g_{1} &= \bigl(2(x_{1} - 1), 2x_{2}, - 2(x_{3} - 1), 0, 0\bigr), \\
\nabla g_{2} &= (1, 0, 0, 1, 1),
\end{align*}
and the gradient vectors at $p$ are
$$
n_{1} = (-2, 0, 2, 0, 0),\quad
n_{2} = (1, 0, 0, 1, 1).
$$
The resulting system of equations $\langle n_{i}, x\rangle = 0$ has coefficient matrix
$$
\left[\begin{array}{@{}rcccc@{}}
-2 & 0 & 2 & 0 & 0 \\
1 & 0 & 0 & 1 & 1 \\
\end{array}\right].
$$
Gaussian elimination converts this to the reduced row-echelon matrix
$$
\left[\begin{array}{@{}ccccc@{}}
1 & 0 & 0 & 1 & 1 \\
0 & 0 & 1 & 1 & 1 \\
\end{array}\right],
$$
from which we can solve for $x_{1}$ and $x_{3}$ in terms of the free variables $x_{2}$, $x_{4}$ and $x_{5}$:
$$
x_{1} = -x_{4} - x_{5},\quad
x_{3} = -x_{4} - x_{5}.
$$
Successively setting each free variable to $1$ and the other free variables to $0$ gives a basis of $T_{p} S$:
$$
w_{1} = (0, 1, 0, 0, 0),\quad
w_{2} = (-1, 0, -1, 1, 0),\quad
w_{3} = (-1, 0, -1, 0, 1)
$$
Now orthonormalize. Gram-Schmidt gives
\begin{align*}
u_{1} &= w_{1}, \\
u_{2} &= \tfrac{1}{\sqrt{3}} w_{2}, \\
u_{3} &= \tfrac{1}{\sqrt{15}}(1, 0, 1, 2, -3).
\end{align*}
Finally, if $v = (v_{1}, v_{2}, v_{3}, v_{4}, v_{5})$ is an arbitrary vector at the origin, its projection into $T_{p} S$ is
\begin{multline*}
\langle v, u_{1}\rangle u_{1}
+ \langle v, u_{2}\rangle u_{2} + \langle v, u_{3}\rangle u_{3} \\
= v_{2} u_{1}
+ \left(\tfrac{-v_{1} - v_{3} + v_{4}}{\sqrt{3}}\right) u_{2}
+ \left(\tfrac{v_{1} + v_{3} + 2v_{4} - 3v_{5}}{\sqrt{15}}\right) u_{3} \\
= v_{2} (0, 1, 0, 0, 0)
+ \left(\tfrac{-v_{1} - v_{3} + v_{4}}{3}\right) (-1, 0, -1, 1, 0) \\
+ \left(\tfrac{v_{1} + v_{3} + 2v_{4} - 3v_{5}}{15}\right) (1, 0, 1, 2, -3).
\end{multline*}