Optimal algorithm to distinguish given black box access
You need $\Omega(2^n)$ samples in order to accomplish your task.
Consider an algorithm that gets $m$ samples from $D$ and then another sample, either from $D$ or from $U$, and has to guess which it is. Its input thus consists of $m+1$ samples $X_1,\ldots,X_m,Y$.
We will generate the distribution $D$ at random by choosing a random set $V \subseteq \{0,1\}^n$ of size $2^{n-2}$ and letting $D$ be a uniform sample from $V$. Note that $d_{\mathrm{TV}}(D,U) = 3/4$.
Consider now the following two distributions:

Distribution $\mathcal{D}$: Choose $D$ at random as above. Generate $m+1$ samples from $D$.
Distribution $\mathcal{U}$: Choose $D$ at random as above. Generate $m$ samples from $D$ and one sample from $U$.

Let $S$ be the set of vectors appearing in the first $m$ samples. We can describe the distribution of the final sample as follows:

Distribution $\mathcal{D}$: With probability $|S|/2^{n-2}$, output a random element in $S$ (each one is output with probability $1/2^{n-2}$). Otherwise, output a random element not in $S$.
Distribution $\mathcal{U}$: Output a random element.

To see where the alternative description of $\mathcal{D}$ comes from, notice that given $S$, the conditional distribution of $V$ is a random set of size $2^{n-2}$ containing $S$. When sampling a random element from $V$, we have a probability of $|S|/2^{n-2}$ to choose one of the elements from $S$, with probability $1/2^{n-2}$ each. Otherwise, we choose an element from $V \setminus S$, which given the distribution of $V$, is just a random element not in $S$.
This shows that the TV distance between the two distributions is
$$
\mathbb{E}\left[|S|(1/2^{n-2} - 1/2^n)\right] &lt; \frac{m}{2^{n-2}}.
$$
In particular, any algorithm whatsoever will behave almost the same in both cases unless $m = \Omega(2^n)$. Indeed, your algorithm $A$ satisfies
$$
\Pr_{\mathcal{D}}[A=1] - \Pr_{\mathcal{U}}[A=1] \geq \frac{3}{4} - \frac{1}{4} = \frac{1}{2},
$$
showing that the variation distance between $\mathcal{D}$ and $\mathcal{U}$ is at least $1/2$. This is only possible if $m/2^{n-2} \geq 1/2$, that is, if $m \geq 2^{n-3}$.