HUD is short for heads-up display, which is a method of displaying (usually graphical) information in a way that overlays normal vision. For example, icons or other info can be displayed on the window in front of a pilot in an aircraft. This allows a pilot to be notified of important information while not taking their eyes off the terrain or opponents while flying.
In video games, HUD usually refers to the graphical information around the edges (or if translucent across the entire screen) of the 'main' playing window. So in first person shooters the symbol for the weapon you are carrying, the ammo it is loaded with, and your health levels are usually part of the HUD.
UI, or user interface refers to all the methods for interacting with a system (or game), both system to user (vision, sound, tactile) and user to system (mouse/keyboard/other controls). Joysticks, mice, microphones, switches, buttons, keyboards, pedals, lights, speaker sounds, and anything displayed on a computer monitor are all part of the UI. As James Smith says in his answer, a HUD is a (sub)part of the total UI.