If it's a small sample that's intended to be representative of a larger population, you divide by N-1 (rough explanation: because you are sort of underestimating the amount of variation that exists when you take a sample of a larger group - it's unlikely that you've captured the 'true range' of all possible values in a smaller sample, so the N-1 is intended to compensate for that).
If you have a sample and you are just trying to deduce data about that sample alone (and not apply it to a larger group), you use N (here you have the full scope of data you are trying to measure, you're not just looking at a smaller portion).
So to use a real example: say you were at a zoo and there are 100 beavers there. I give you the weight of each beaver and ask you for the standard deviation of the weight of beavers at the zoo. You would use N in the standard deviation formula - we are only analyzing the weight of beavers in the zoo, and we have all the data we need.
If I asked you for the standard deviation of the weight of all beavers on Earth, and to use the zoo beavers as your sample, you would use N-1 (the data is based on a sample smaller than the entire group you are trying to measure - if you were to use N here you'd be underestimating the true amount of variation that exists).