Step 1. Denote $d=\mathrm{dist}(f,A) := \inf\{\lVert f- a\rVert : a \in A\}.$ For each $n\in\mathbb N$, we can take $y_n\in A$ such that $\|f-y_n\|<d+\frac1n$. We show that $\{y_n\}$ is Cauchy.
We use Parallelogram identity to compute $\|y_n-y_m\|^2$. For each $n,m\in\mathbb N$, we have
\begin{align*} \|y_n-y_m\|^2&=\|(f-y_n)-(f-y_m)\|^2\\
&=2\left(\|f-y_n\|^2+\|f-y_m\|^2\right)-4\left\|f-\frac{y_n+y_m}2\right\|^2\\
&\leq 2\left(\left(d+\frac1n\right)^2+\left(d+\frac1m\right)^2\right)-4d^2\\
&=4\left(\frac1n+\frac1m\right)d+2\left(\frac1{n^2}+\frac1{m^2}\right). \end{align*}
From this we can easily show that $\{y_n\}$ is Cauchy.
Since $A$ is closed, the limit $a=\lim y_n$ belongs to $A$. We also have $\|f-a\|=d$.
Step 2. Now we prove that $\langle a - f,b\rangle = 0$ for any $b\in A$. We may assume WLOG that $b\neq 0$. For any $t\in\mathbb R$, we have $tb+a\in A$, hence $\|a-f+tb\|^2\geq d^2=\|a-f\|^2$ for all $t$, i.e., (Here I assume that the Hilbert space is over $\mathbb R$. If $H$ is a complex Hilbert space, this argument needs to be slightly modified.)
$$t^2\|b\|^2+2\langle a - f,b\rangle t+\|a-f\|^2\geq\|a-f\|^2,\qquad\forall t\in\mathbb R.$$
Or equivalently,
$$t^2\|b\|^2+2\langle a - f,b\rangle t\geq 0,\qquad\forall t\in\mathbb R.$$
This implies that $\langle a - f,b\rangle = 0$ by taking $t=-\frac{\langle a-f,b\rangle}{\|b\|^2}$. Indeed, this $t$ also can be used for complex Hilbert space $H$! If $H$ is complex and $t=-\frac{\langle a-f,b\rangle}{\|b\|^2}\in\mathbb C$, then we have
\begin{align*}
\|a-f\|^2\leq \|a-f+tb\|^2&=\|a-f\|^2+\bar t\langle a-f,b\rangle+t\overline{\langle a-f,b\rangle}+|t|^2\|b\|^2\\
&=\|a-f\|^2-\frac{|\langle a-f,b\rangle|^2}{\|b\|^2},
\end{align*}
which gives that $\langle a-f,b\rangle=0$.
Step 3. Uniqueness. If $a, a_1\in A$ satisfy $(f-a)\perp A$ and $(f-a_1)\perp A$, then $a-a_1=(f-a_1)-(f-a)\in A^\perp$. That is, $\langle a-a_1, b\rangle =0$ for all $b\in A$. Taking $b=a-a_1\in A$ gives that $\|a-a_1\|=0$ and thus the uniqueness.