To use specialists well you should first read the opening section on TileImprovements that explains how a city collects resources.
Next the most important thing to understand when assigning a specialist is that the worker that is removed from collecting resources is the last citizen that was added to the city.
For example in a size 7 city, if you add one scientist specialist the 7th worker of that city will be removed from the 2nd ring of a city's radius. This means the 2nd ring of the size 7 city will no longer be worked at 1/12 efficiency, but you will gain a scientist. The 1st ring will continue to be worked at 100% efficiency too.
This is important because when removing a worker from a ring, you should consider how many resources that worker would have been collecting. You have to decide if it's more beneficial to use the citizen as a specialist or as a worker in the field.
The types of specialist:
Entertainer: +2 happiness (requires Drama advance)
Farmer: +30 food (requires Agriculture advance)
Labourer: +30 production (requires Industrial Revolution advance)
Merchant: +20 gold savings (requires Economics advance)
Scientist: +30 science (requires Classical Education advance)
It's important to note here that the benefits of each specialist will not always be exactly as they are above, as they are altered by government modifiers. For example a Farmer specialist under Tyranny government with a food modifier of 0.85 will be worth 0.85*30 = 25 food (usually rounded down), in Monarchy with a food modifier of 1 it will obviously be worth 30 food as normal, and under Ecotopia with a food modifier of 1.5 it will be worth 45 food.
So when do you use a specialist and how many?
Let's take this example city:
At size 14 the inner ring is worked at 6/6 or 100% efficiency. With no specialists the second ring is worked at 8/12 or 67% efficiency, but the terrain on the 2nd ring is awful, as glacier terrain produces no resources and the rivers produce very little by themselves.
The actual amount of resources on the 2nd ring is, glacier = 0, 7 river squares = 35 food, 35 production, 35 commerce. Each tile is collected at 8/12 or 67% efficiency so it would be roughly 23 of each resource. Then consider we are also in Tyranny government, so that's 0.85 food and 0.85 production (commerce is unchanged). So that's 19 food and production and 23 commerce, a total of 61 resources collected.
Then consider that 8 workers are toiling away to collect those 61, that's only 7 or 8 resources each - a huge waste of workers.
In this situation it would be far more efficient to remove all 8 workers from the second ring and assign them to specialists, any specialist.
(Note that in-game these numbers won't be exact due to rounding peculiarities, but the point is clear.)