I have the same issue. Setup is:
-- mid-2012 MBP (non-retina) running 10.8.5 (including the very latest supplemental 10.8.5 which was supposed to fix a different issue with an HDMI audio connection not working after a Mac's wakeup from sleep).
-- MBP connected to a Harman Kardon BDS 577 AV receiver's HDMI input (this is a 5.1 receiver, connected to 5.1 speakers).
-- MBP and receiver connected via PNY mini-DP-to-HDMI adapter, which both its Amazon description & review explicitly say supports passthrough audio on Macs, and a high quality AmazonBasics HDMI cable (ditto).
-- The receiver's HDMI output is connected to an Epson EH-TW3200 projector's HDMI input (projector is Euro version of the US Epson 8345; it has no audio whatsoever).
-- The Epson is set to mirror the MBP display, and the MBP's internal display resolution is set to match the Epson's (1080p), which appears as "Epson PJ" in the menubar's Displays pulldown.
1) The issue we're having here is very clearly different from the one with the HDMI connection not working after wakeup (numerous thread about it in Apple Discussions & other forums), since there the HDMI option for sound output device is available (in the Sound Preferences panel, the equiv. menu-bar shortcut and in Audio MIDI Setup and VLC Audio --> Audio Device submenu), but didn't work properly after wakeup.
2) With our issue, when everything is connected but the projector is turned off, sound works fine. I have the option to select HDMI in all the aforementioned locations (the device is called "HDMI TV"), and, when chosen, sound is properly output via the AV receiver according to the source material (5.1 with both DTS and AC3 encodings work fine, as does stereo).
3) As soon as the projector is turned on, video appears fine as expected on the projector, mirroring the MBP's screen, but the HDMI option disappears from all above lists of sound output devices. If I was in the middle of a movie on VLC, audio switches to the builtin speakers on the MBP.
4) Trying to trick the sytem by defining a new audio aggregate device in Audio MIDI Setup when the projector is off, having it include the HDMI device, and then trying to choose it when the projector is on doesn't work -- the aggregate device is grayed out and can't be chosen.
5) TjoffenF's solution above doesn't help me: For me VLC behaves exactly like the rest of the system, so using it doesn't help. I tried several versions of VLC, including old (1.1.2) & new (2.0.9, 2.1.4).
6) Jackmo69's solution doesn't work for me either: The order the various components are switched on and/or connected doesn't matter. As soon as the projector is on, HDMI audio option simply disappears and the MBP stops using the HDMI port for audio.
7) Generally, this seems to be a problem with something called EDID. This is the protocol which HDMI and DVI devices use to tell each other about their capabilities (resolution, audio supported, etc.). Somehow the Mac thinks the HDMI device it is attached to has no audio at all, so it falls back to its internal speakers. I initially thought the problem was with my AV receiver -- whether or not the projector is turned on, it should report its own EDID, not the projector's, so I shouldn't have seen the "Epson PJ" option, right?
8) I contacted the local tech support for Harman Kardon. They hadn't heard of an issue with their receiver, but don't have Macs. From their POV, which sounded reasonable, if the issue occured with a PC laptop, they'd agree that their equipment was the culprit. They lent me a a Windows7 laptop with a builtin HDMI port (Dell Studio 1558) for a week to test.
I performed hours of experiments with it, replacing the MBP with the Dell, all other things in the setup being identical with the exception of the PNY adapter (same AV receiver, same projector, same cables, same VLC version, same source files).
9) The result:
With the Dell, all the source files output audio via HDMI to the receiver with no issues, and turning the projector on or off has no effect on the audio. To me, this proves that the issue is the Mac, probably an HDMI driver issue. AFAIK the PNY & similar adapter are simple mechanical adapters (the actual video signals are identical), so given it transmits audio fine from the MBP (when the projector is off) I don't see how the adapter could be the problem (I don't own a TV, so couldn't test with one).
10) Extensive googling yielded a couple other people with similar problems using various Macs (earlier but still post-2009 MBs and MBPs as well as a Mac mini), projectors and AV receivers. Their solutions were to (a) run TOSLINK audio seperately from the Mac to the receiver (not an option for me, since my receiver accepts TOSLINK only for an audio-only source) or (b) use an EDID emulator device, which spoofs the EDID so the Mac will agree. There was at least one person who had the issue appear after upgrading fromOS X 10.6 to 10.8 (Mac and other components didn't change), which is yet another indication this is a Mac driver issue.
10) I really don't like the idea of EDID emulators; it's a kludgy solution (needs its own power supply and additional HDMI cable), expensive ($100-$150), and not available locally. Reports on them say they don't always work.
11) I'm very much ****** at Apple at this point. The only solution I can see right now is to buy a media streamer with HDMI output, to circumvent the problem -- not an ideal solution, since it means adding a middleman, but cheaper and and more likely to work then an EDID emulator. (Incidentally, an Apple TV wouldn''t work for me as a streamer because it supports very few video codecs & file types -- not that I'd be happy to give Apple more money to fix a problem they're reponsible for.)
If anyone has since found another solution, I'd realy appreciate hearing about it.