That video card does not have any built in audio. To get audio over HDMI from it it has to have a SPDIF cable from it to the SPDIF header on the motherboard (or sound card if one is used instead). As a result it uses whatever driver is installed for the onboard audio which when you say,
it says realtek audio optical when i plug in the hdmi to the g100 graphics card.
then it is switching to the correct setting (SPDIF is digital).
Seeing as Acer conveniently provided instructions on what to check inside the computer when the HDMI audio doesn't work, follow that link I posted and check the cable and connectors, and reverse it as shown.