Flags are an excellent way to signal information to other vessels; but to properly communicate, you need to know flag grammar.
First off, the flag on your stern pertains to the country you pertain to. If your boat is a US vessel, you would fly a US flag (50 star flag); if your boat is German, you would fly the German flag. When you are sailing in your national waters, you can fly that countries ensign flag in lieu of the national flag. When overseas, this practice is not allowed and you must fly your national flag.
The size of this flag is dependent on the length of your yacht, the typical guideline is 1 inch on the fly (horizontal length of flag) for every foot of boat length. Flags come in several standard sizes and you should always round up to the next commercially available size.
The port spreader halyard is the correct location to fly club burgees and other personal flags. This side is considered the personal flag side of the boat. It is recommended that you only fly one burgee on the halyard as opposed to flying every burgee you have on board.
The size of these flags is typically 1/2 inch on the fly for each foot above water that they flag is flown; ie. a 15 inch flag when the spreader is 30 feet above the water.
While the port spreader flies personal flags, the starboard spreader flies regulatory flags. This halyard is where the yellow quarantine flag is flown until customs are cleared, at which time it is switched over to the countries courtesy flag. These flags are also sized as 1/2 inch on the fly for every foot above water that they are flown.
Distress can also be expressed by way of altering the national flag or ensign. Commonly accepted distress signals are flying the stern flag upside down or tying a knot in the fly of the flag. Both of these signals are accepted as daytime visual distress signals and should only be done during an actual situation of distress.
One of my neighbors was displeased with the US election results in 2012 and hoisted the US flag upside down to the top of his mast while tied up in the marina and the marine police actually came into the marina to investigate the situation and help this boater in his time of distress. When they learned of his reasoning, he was ordered to lower the flag since he was not in distress.
Now you know which flags are to raised and where. Country flag on the stern, personal and club flags on the port spreader, courtesy and signal flags on the starboard spreader.