This question is so common and often followed by a confusing answer. So here it is all spelled out.
Ensign:
This is the owners national maritime flag. It is not flown all the time. By tradition, it is hoisted when someone is onboard. It should be hoisted at 0800 (or 0900 in the winter) and lowered at 2100 or Sunset which ever comes first.
It should be lowered when
racing.
The Ensign takes pride of place. It is after all your country that you are representing. In fact it came from the old days when the Ship was Sovereign Teritory. The stern is the normal pride of place, but a Ketch/yawl may fly it from the Mizzen
mast head. The ensign is normaly flown from a
Mast stick mounted to the transom or davits or even backstay.
On sailboats it has become much harder to find places to fly flags from. So the next best point is the main
mast under the Starboard spreader.
One act that is not done much anymore, is to dip your Ensign to a Royal Yacht or Warship. Once you have dipped, you wait for a dip from the other ship and wait till they rehoist. Then you may rehoist your onw Ensign. Don't be disapointed if a Warship does not do this for you, they tend to be rather busy these days watching out for us little fellows below than whether you have dipped your ensign or not.
Club Burgee:
This flag takes second pride of place. It is your club afterall.
You do not fly any more than one club burgee at a time.
You do not fly your club burgee when
racing.
The normal place to fly a Burgee is from a flag stick at the main mast
head. Not such an easy place to reach on a sailboat. So from the lower spreader on the Starboard side right under the Ensign.
This is also a flag that is flown only when someone is onboard.
Courtesy Flag:
Any vessel visiting a Foriegn port should fly that countries
Marine ensign out of courtesy, or in other words, you are ackowledging the soveriegnty of that country. This is a tricky one. It must never be flown "inferior" to any other flag. So this means you may have to transfer your Club Burgee to the Port side spreader and the Courtesy flag is flown from the Starboard side spreader.
Quarantine Flag:
This is a yellow flag that is flown upon entry to a foreign Port. Failure to do so can cause all sorts of issues. Flying a yellow flag means you are declaring that your vessel and persons on board are healthy and that you require free Pratique and Customs Clearance.
Divers Flag: Also known as the "A" Alpha Flag
This is a white and blue flag that is flown when you have someone in the
water diving(scuba). This warns other vessels to keep well clear and/or proceed at a slow speed of 5kts.
Other Flags:
These don't normaly pertain to us plain simple folk. But it maybe handy to know what they mean for the sake of knowing what some other, normaly larger vessel maybe doing or requiring you to do.
An all Red flag, also known as the "B" Bravo flag, means danger. Normally seen on Tankers etc. Any Vessel that is carrying cargo that is deemed dangerouse.
Yellow and Blue strips...means that the large vessel is requireing a Pilot. It could be worth being cautious.
White and Red...means the Pilot is on board and under his/her command. It is still worth excersising care as there maybe a fast moving Pilot vessle runnign around after dropping off or picking up his Pilot.
Blue around the outside of a White Flag, also known as the "P" Papa flag,... means the vessel is about to precced to sea.