An electron can be excited to a higher energy level/orbital by absorbing a photon of specific frequency. This frequency corresponds to a specific energy (E=hf), the energy is equal to the energy gap between the energy levels.
If this frequency is within the visible region of the electromagnetic spectrum, then the compound will appear to be coloured. The colour of the compound is the complement of whichever colour of light is absorbed.
There's more to it and its a bit more complex than that in reality, but that's the best way i can explain it. Hopefully i wasn't completely incorrect somewhere.