Hat
A hat was an article of clothing worn on the top of the head.
The Doctor's hats
In the majority of his lifetimes, the Doctor wore a hat on a regular or semi-regular basis. Only three incarnations — the Sixth, Ninth and Tenth Doctors — showed no particular interest in hats.
First Doctor
The First Doctor's usual hat of choice was a karakul or Astrakhan, a triangular hat often associated with Afghanistan, or what one account called an "oddly shaped fur hat". (PROSE: Doctor Who and an Unearthly Child) It was this hat he was wearing when he met Barbara Wright and Ian Chesterton, as well as during his first adventure with Ben Jackson and Polly Wright. (TV: An Unearthly Child, The War Machines) However, he was also known to possess a kind of Panama hat, which he wore in hotter climes. He donned a white Panama when he was on the hunt for the Daleks' taranium in Egypt. (TV: "Escape Switch")
This incarnation was not averse to occasionally playing dress-up. When in Revolutionary France, he obtained period-appropriate wardrobe. Because the costume was that of a regional official, his hat was particularly elaborate, bearing a strong resemblance to an early 18th century French army officer's hat. (TV: "A Change of Identity")
Second Doctor
Early on, the Second Doctor was particularly obsessed with hats. One of his very first acts after regeneration was to rummage through a trunk in the TARDIS to find a stovepipe hat to wear. He wore the hat throughout his first adventure on Vulcan. (TV: The Power of the Daleks)
He sometimes uttered the phrase, "I would like a hat like that (or this)" if he saw a hat he particularly fancied. (TV: The Power of the Daleks, The Highlanders) In fact, when he arrived in Scotland in the 18th century, he happened across a Balmoral bonnet on a field of battle and immediately donned it. Later in the same adventure, he wore a British Army tricorn as a disguise.
On a trip to Atlantis, he briefly returned to the stovepipe, but continued to show his penchant for disguise by temporarily donning a gypsy headdress to appear as a merchant. It was here, too, that Polly noted his fondness for hats. When he began enthusiastically eating food made of plankton, the Doctor's praise was effusive. When Ben wondered why the Doctor was so excited, Polly replied, "I don't know. I've never seen him go for food like this before. It's usually hats." (TV: The Underwater Menace)
Third Doctor
Like his predecessor, the Third Doctor almost immediately donned a hat after his regeneration cycle ended. He found a trilby amongst a physician's clothes at the Ashbridge Cottage Hospital. When he tried it on and looked in a mirror, he seemed to give it a look of approval. (TV: Spearhead from Space) However, he wore it only briefly and generally was without a hat for the rest of his life.
Fourth Doctor
Just like his previous selves, the Fourth Doctor's initial clothing instincts were to reach for a hat after his regeneration. His outfit was supplied entirely from the TARDIS wardrobe and he tried on a variety of outfits, most of them with hats. Amongst the rejected hats were a Viking helmet and a tall clown's hat. Finally he settled on a wide-brimmed fedora. Unlike the two incarnations before him, however, he fairly consistently used this hat or ones very like it throughout his life.
On occasion, he substituted another hat, such as when he too donned a Balmoral bonnet whilst in Scotland. (TV: Terror of the Zygons) He also wore a sombrero when he thought he was arriving in Benidorm, Spain. (COMIC: Doctor Who and the Star Beast) He also wore a deerstalker while visiting Victorian London to go along with his Sherlock Holmes outfit. (TV: The Talons of Weng-Chiang)
Fifth Doctor
Like the incarnation before him, the Fifth Doctor had a regular hat, which he wore throughout his life. From his first adventure, he carried with him a roll-up Panama hat with a hat band of the same colours as the rest of his outfit. He tended to wear it upon first exiting the TARDIS in a new location, but often quickly rolled it up and put it back in his jacket.
Seventh Doctor
Like the Fifth Doctor, the Seventh Doctor also had a Panama hat, though it was of a different design. He wore it constantly, even when indoors. He typically removed it from his head to greet others. (TV: Time and the Rani - Survival) When he took to wearing a darker jacket, he also changed his hat into a subtly darker one. (TV: Battlefield)
Eighth Doctor
After his regeneration in San Francisco on 31 December 1999, the amnesiac Eighth Doctor ransacked the lockers of the hospital staff for a new outfit. He decided against the stetson that went with the "Wild Bill Hickok" costume which he chose to steal. (TV: Doctor Who)
The Doctor once emerged from the TARDIS wearing a fez when he believed that he had materialised in Egypt. (COMIC: Doctor Who and the Nightmare Game)
On another occasion, when visiting the Lakota Sioux Nation in 1875, he wore a stetson which was given to him by Samuel Clemens. (COMIC: Bad Blood)
Tenth Doctor
The Tenth Doctor showed little interest in hats, although he did once sport a straw hat, along with sunglasses and a lei, implying he had just finished a relaxing time at a beach. (TV; The End of Time) He also donned a sombrero on the beaches of Centuria. (COMIC: The Power of the Cybermen)
Eleventh Doctor
The Eleventh Doctor wore a variety of hats, seeking to aquire unique ones. This Doctor, even more so than the Second Doctor, possessed a rather obsessive desire to wear a hat; he'd get distracted by a hat he liked even while running away from enemies. (TV: The Big Bang, The Curse of the Black Spot) He considered damaging a hat to be offensive. (TV: A Town Called Mercy) Unfortunately for him, his wife has a habit of shooting his hats right off his head. (TV: The Big Bang, The Impossible Astronaut)
While in the National Museum, he found a fez of which he became instantly fond of. The fez was later removed by Amy Pond and destroyed by River Song. Undeterred, he noted to himself that it would be easy to buy another one. (TV: The Big Bang) He wore one while acting as an extra in a film Rory and Amy were watching (TV: The Impossible Astronaut), and even aquired one previously owned by his old pal Albert Einstein. (TV: Death is the Only Answer) He later wore one on a Christmas trip with Kazran Sardick and Abigail Pettigrew to Egypt. (TV: A Christmas Carol)
Perhaps losing interest in fezzes, the Doctor later showed a fondness for stetsons, being given one by Craig Owens as a gift for his trip to Utah. (TV: Closing Time) He wore his gift during his investigation to find out why the Silence wanted him dead, and made the Teselecta copy the stetson along with his form. The copied Stetson was shot off by River. (TV: The Impossible Astronaut/The Wedding of River Song) Having not brought his own with him, the Doctor borrowed a stetson that had been damaged by a shot fired by the Gunslinger. (TV: A Town Called Mercy). However, the Doctor seems to keep the fez, using it as a tip basket (TV:The Bells of Saint John]])
This version of the Doctor also owned a top hat, which he wore at Amy and Rory's wedding, (TV: The Big Bang) after having been poisoned by River in Nazi Germany (TV: Let's Kill Hitler) and again to conceal a device that allowed him to lure the Squall back into their dimension of origin (PROSE: Paradox Lost). He also wore one as part of his Victorian Era clothing while brooding over the loss of Amy and Rory. (TV: The Snowmen)
While posing as Sherlock Holmes, he also wore a deerstalker hat similar to the one his fourth incarnation had during a previous visit to Victorian London. (TV: The Snowmen) Later, the Doctor wore a bowler hat. (TV: The Crimson Horror)
The companions' hats
Those companions attached to UNIT or other armed forces wore hats as a part of their uniforms. Ben Jackson's sailor's cap, for instance, identified him as a member of the crew of the HMS Teazer. UNIT officers, like the Brigadier and Captain Mike Yates, most often wore a rigid, green-and-red officer's cap, similar to the British Army. Surgeon-Lieutenant Harry Sullivan's black, white and gold hat — otherwise quite similar to the standard Army issue — betrayed his secondment from the Royal Navy. Sergeant John Benton most often wore a beret in the field. Indeed, UNIT soldiers and officers alike wore berets in the field. Over the years, the standard-issue UNIT field beret changed from chocolate brown (TV: The Ambassadors of Death) to khaki green (TV: Terror of the Autons) to United Nations blue (TV: Battlefield) to red. (TV: Aliens of London, Planet of the Dead)
Although not in the military, a couple of companions nevertheless had headwear that was a part of a uniform. Tegan Jovanka had a triangular cloth cap as a part of her stewardess' uniform, but she largely abandoned its use after meeting the Fourth Doctor and Adric. (TV: Logopolis) Likewise, while Nyssa of Traken was "in uniform" as a Trakenite royal, she wore a tiara. (TV: The Keeper of Traken)
These exceptions aside, most companions simply didn't wear hats on anything like a regular basis. A few wore the occasional hat strictly as a fashion accessory, often whimsical.
In both her incarnations, Romana was fond of wearing hats. Romana I wore a flat cap on her first visit to Earth (TV: The Stones of Blood) and an elaborate purple-and-green hat that was "what everyone . . . [was] wearing" on Tara. (TV: The Androids of Tara) Romana II briefly toyed with wearing the Fourth Doctor's fedora after her regeneration. She later wore a boater when punting in Cambridge (TV: The Five Doctors) and a straw sun hat whilst on a beach. (TV: The Leisure Hive)
Liz Shaw generally didn't go in for hats, but did once wear a white, broad-brimmed hat to drive Bessie. (TV: The Ambassadors of Death) Likewise, Sarah Jane Smith was mostly hat-less but did wear a casual spring hat whilst investigating Think Tank. (TV: Robot)
Behind the scenes
In the video game The Eternity Clock, the Doctor's collectible items are various hats (including the fez, top hat and Stetson).