Assuming coin flips are independent, the number of heads has a binomial distribution with mean $np$ and variance $np(1-p)$, where $n$ is the sample size and $p$ is the true success probability.  To construct the interval you first specify the confidence level (often taken to be 95%). You can compute the confidence interval for the exact binomial using what is called the Clopper-Pearson method. If the sample size is large such as the 500 you posed as an example, then you can use the normal approximation to construct the interval.  If the interval contains 0.5 you cannot reject the hypothesis that you have a fair coin.  If 0.5 lies outside the interval you would conclude that the coin is biased with a significance level equal to 1 - the confidence level, where the confidence level is expressed as a proportion.