Two-sample t statistic
A two sample t-test assuming equal variance and an ANOVA comparing only two groups will give you the exact same p-value (for a two-sided hypothesis).
t-test assuming equal variance
F = t2 and both p-values are the same.
But the t-test is more flexible: You may choose a one-sided alternative instead, or you may want to run a t-test assuming unequal variance if you are not sure that your two populations have the same standard deviation .