There are two main cases in which you should use an apostrophe
Singular Possession
Apostrophes are used to indicate possession. The rule for indicating possession with singular nouns is, in most cases, simple: add an apostrophe plus the letter s. Let’s look at some examples.
 the dog’s hat   That man’s ear is on fire. 
Adding an apostrophe and an s indicates that the hat belongs to the dog. Using the possession rule, we can show that the ear belonging to 'that man' is on fire.
 Shaun’s cat is called Tango.   Chris’s surname is Daveson. 
The rule applies for most personal names, too. Things get a little more complex when dealing with personal names ending in s. The general rule is to add an apostrophe and an s when you would naturally pronounce the additional s if reading aloud.
 Mr Hutchins’ ear is on fire.   the dog’s hats 
If you would not pronounce the additional s, you just add an apostrophe. This rule applies to singular nouns only. There can be multiple 'hats', like in this example, but there must only be one 'dog'.
 Alice likes 'Doctor Who'’s stunning visual effects.   Alice likes the stunning visual effects used in 'Doctor Who'. 
Possession of things that are in quotation marks is a grey area. There is little in the way of official guidance. The example given is a perfectly valid way of punctuating. Sometimes it’s possible to avoid structuring in this way, like in this example, avoiding the use of the apostrophe entirely.
Plural Possession
When the noun is plural and ends in an s, the rule is to add just an apostrophe. However, for the rare nouns that are in plural form but do not end with an s, the singular possession rule applies.
 the dogs’ hat   the dogs’ hats 
The hat belonging to the dogs. As 'dogs' is plural and ends with an s, only an apostrophe is added to the end. The hats belonging to the dogs. Notice that whether the object is singular or plural, it does not change the rule.
 Lots of people’s ears are on fire.   The children’s toys are on fire. 
Even though 'people' is plural, it does not end with an s, so the singular possession rule applies. Again, though 'children' is plural, it does not end with an s.
 The Davesons’ motives are suspicious.   The Hutchinses’ surname is complicated. 
Things start to get quite complicated when it comes to plural names. Here, the writer is suspicious of the Daveson family’s motives. As their surnames are Daveson, the family is collectively referred to as the Davesons. As this is plural, just an apostrophe is added. The Hutchins family here are collectively referred to as the Hutchinses. As this is plural, just an apostrophe is added.
Joint and Separate Possessions
Here are some examples of how to deal with joint and separate possessions. If the object belongs to all individuals, the previously established rules apply to the final individual’s name only. If the object belongs to each individual separately, the previously established rules apply to each individual.
 Shaun and Chloe’s coursework.   Shaun’s and Chloe’s coursework. 
This sentence implies that the coursework belongs to both Shaun and Chloe. This sentence talks about the coursework belonging to Shaun, and the coursework belonging to Chloe.
A Double Possessive
Sometimes, it’s possible to find yourself in a situation where a double possessive is needed. In general though, there is a way to reword the sentence to avoid this.
 Shaun’s cat   Shaun’s cat’s phobia 
Using previously established rules, this fragment refers to the cat belonging to Shaun. This is an example of a double possessive. This fragment refers to the phobia the cat has. The cat belongs to Shaun.
Another case in which you should use an apostrophe is to indicate the omission of part of a word or words. The apostrophe should be placed where the omitted letters would be.
 The dog’s crazy about hats.   I’m scared that my ears will burn. 
The apostrophe here is not possessive. It instead implies that something has been missed out. In this case, 'dog’s' is short for 'dog is'. This style of writing should never be used in formal situations. Here, 'I’m' is short for 'I am'.
 That’s Shaun’s cat, not Ryan’s.   The Hutchinses’ fo’c’s’le’s sailors’ ears are on fire. 
Both 'types' of apostrophe can be used in the same sentence. Here, the omission apostrophe is used in 'that’s' ('that is'), while the possessive apostrophe is used in 'Shaun’s' and 'Ryan’s'. Things can get very, very complicated if you let them. This is an example of a sentence that, though technically correct, is silly and should be avoided. (The ears of the sailors in the forecastle that belongs to the Hutchins family are on fire.)
Its and It’s
There are two types of it: it’s and its. It’s is short for it is, whereas it means belonging to it.
 Honey, it’s not feasible to keep buying hats for the dog.   Its face fell when it realised that there were no more hats. 
It is not feasible to keep buying it hats. The face belonging to it fell.
In general, never use an apostrophe to pluralise a word. In almost all cases, this is wrong. However, there are very few cases where using an apostrophe is acceptable for the sake of clarity.
 His ears became ash.   Dot the i’s and cross the t’s. 
'Ears' should not have an apostrophe because it is simply a plural, referring to more than one ear. Using an apostrophe for the plurals of single letters is acceptable.
 Find all the number 42’s.   I miss the 90’s. 
Using an apostrophe for the plurals of numbers is acceptable. Some style guides prefer that apostrophes are used when talking about groups of years. However, there is no clear consensus and so you should do whatever you feel most comfortable with.