Simply put, there are three instances when the whistle should be blown.
The whistle should never be blown during active play to indicate the play should continue or that you are playing the advantage.
The whistle is a means of communication, the tone and length of your whistle can convey how you feel about a particular situation. However a single short sharp blow should be all that is needed for most situations.
Much has been written about how long you should blow the whistle to start the game vs. how long you should blow it for a free kick. It is not necessary to worry about this. If a player has just fouled someone I doubt they will deduce from the length of your whistle that you intend for the second half to start right now. Similarly if there are two players standing in the center circle with the ball on the center mark at the start of the second half, it is unlikely that they will think that you have spontaneously decided to award a penalty from the length of your whistle. It is necessary just to blow it so that it can be heard and understood.
If it is obvious that the ball has gone out of play or left the field, there is little point in blowing the whistle. This goes for goals as well. It is only necessary to point to the center circle after an obvious goal has been scored. If there is some question whether the ball is in play or not, or if a goal has been scored or not, then blow the whistle only if the ball is out or the goal has been scored. I find for the younger age groups that it helps to point in the direction of the throw and to also call out the color of the team who should throw it. It saves confusion and keeps the game moving.
For free kicks it is necessary to blow the whistle to award the free kick, but it is not necessary to blow it before the free kick is taken. A quickly taken free kick is part of the game and should not be discouraged. The exception to this is if you tell the attacking team to wait for your whistle so that you have enough time to carry out some other chore you may have, such as showing a red or yellow card, or moving a wall back 10 yards. If the player does not wait, you should show them a yellow card for unsportsmanlike conduct and have the kick retaken. This is probably a bit harsh for the younger age groups.
If you wish to draw the attention of a player, for instance if they are taking a free kick from the wrong location, blow the whistle once as you approach them and give them verbal instructions. If they ignore you blow it again with more force.
The whistle can be used to prevent a situation from arising or continuing, such as when two players face each other down in a threatening way while the ball is not in play. Approach the players and blow the whistle a number of times to indicate that you will tolerate none of that.
At the end of the game or half, point to the center circle and blow the whistle three times. This indicates the game is over. It can be distinguished from your gesture indicating a goal has been scored by the fact you blew the whistle three times.
Constant unnecessary use of the whistle can cause players to tune you out, much the way they tune out their parents. You want the players to realize when they hear a whistle that the ball is dead and they need to look at you to see what your call is.
Again remember blowing the whistle during active play means stop.
If you blow your whistle by accident play must stop, and the correct restart is a drop ball at the location where the ball was when you blew your whistle.
Stop! – Free kick, ball out of bounds, etc
Don’t even think about it, cut it out (good to prevent trouble before it escalates)
Game over/Half time