we all know that electrons,photons, phonons can excite an electron from valence band to conduction band...i think the main difference between electronic bandgap and optical bandgap is that in electonic its the energy required for an electron to move from the valence band to the conduction band.but in optical bandgap photons(packet of energy in the form of light waves) are assisting the electrons to move from valence band to conduction band.
The difference between optical and electronic bandgap is more complexe actually. The optical bandgap is the one that can be measured using optical techniques (based on transmission and reflection, i.e. Tauc plot). However, this measurement does not take into account all traps you might have within the bandgap that can modify the energy required to move one charge carrier from the conduction band ans the conduction band. The electronic band gap (which is the one of interest in fine, in an integrated device) is measured under operation. Thus, for many devices (lasers, solar cells...etc.) the electronic bandgap (energy required to get the device working) can defer from the optical bandgap.