Hats are accessories only usable on Pets.
Player-characters cannot wear hats as of yet (R26 in December 2015).
Currently you can find top hats of 4 different colors and party hats of 3 different colors solely in all kinds of Treasure Chests that will randomly spawn in dark places on all Creativerse-game-worlds.
The Holiday Pet Hat is an exception; it will only spawn in colorful Holiday Gift-boxes randomly spawning in large numbers during the (ingame-)day on the surface of all Creativerse-worlds during holiday-times like from 14-12-2015 to R27 (expected to come in mid-January 2016).
To put hats on your pets, open their pet-windows by right-clicking the pet or typing "f" (as the default-key) when standing in front of your pet and looking at it. Than right-click the hat in your inventory (that will automatically open up too whenever you open the pet-window) or drag & drop it from your inventory to the topmost accessories-slot of your pet. Voilà!