Which graphics card do you have? Displays connected over HDMI have worked perfectly for me on machines with Intel HD and AMD Radeon HD graphics cards (using the open-source graphics drivers in both cases). Audio should also be automatically carried over HDMI as long as your graphics driver supports it. The open-source Intel graphics driver, proprietary AMD graphics driver, and proprietary NVIDIA graphics driver should each handled the necessary HDMI audio setup seamlessly. The open-source Radeon driver also supports audio over HDMI, but only with the most recent stable kernel release. The open-source Nouveau (NVIDIA) driver is far behind the others and will likely not support audio over HDMI for quite some time.
Although the kernel drivers (and udev) hint at the switching that needs to be done, userspace also has to be aware. Most full-featured, modern desktop environments have no problem with this, but automatic audio and display switching is likely to be less-than-automatic with some of ligher-weight alternatives. Recent versions of Unity, GNOME, KDE, XFCE, and MATE, at least, should have no problem handling the userland support so long as you are using a supported graphics driver, like I described above.