To dress up a [[Pet[[ of yours (or Pets of other players that you are allowed to access), open the Pet window by using right-click or "f" (default key) while looking at the Pet, then right-click on any accessory that you have found and are carrying in your inventory to move it into the correct accessory slot of the Pet (or to replace the formerly worn accessory with this new one).
If you "dismiss" a Pet, all its accessories will be dropped in its Loot Bag. However if a Pet should go missing because of a bug, the accessory will be lost together with the Pet.
Presently (in May 2017), player characters cannot wear any hats. However helmets have been taken out of the game in 2016 to be revised, so it's very likely that helmet slots will return together with an option to also wear hats somewhen in the future.