The days of bands Pink Floyd and Metallica topping the charts are long gone, and I'm really unsure as to why? When and why did rock music die off in popularity and electronic music take over?
Well, this may be semantics, but rock music continues to have its own charts -- several of them, in fact. If the question is "why is rock music not at the top of the Billboard pop charts?" then I would say it has to do with the shift from a blues based aesthetic of pop music to a gospel and hip-hop based aesthetic. For the last few generations of music consumers, the basic "matrix" within which pop music forms is no longer folk and the blues, with guitars at the center, but soul, gospel, and hip-hop, genres that emphasize looped beats, dance grooves, sampling, elaborate diva-style vocals, and rapping. (I explicitly want to avoid seeming to make a value judgment here; I don't think one is better or more "authentic" than the other.)
Most new pop music is some combination of these styles, and white guys who might otherwise be rocking -- Ed Sheeran -- and white girls who might have wanted to be like Joni Mitchell -- Iggy Azalea -- are forming their styles on that combination.
Meanwhile, new electric guitar music is either super retro and avant-garde (Jack White, St. Vincent) or extremely complex, dark, and avant-garde (metal). A lot of this stuff is awesome, but it is happily unaware of the need to be "popular."
PS: I don't think technology per se is the issue. Plenty of soul/gospel based pop music is being made with explicitly "retro" technology (Amy Winehouse) and a focus on acoustically played instruments (Daft Punk).
I'll assume we are talking about rock as a "guys with guitars" thing here. I'm also focusing more on some of the 'why', as I agree with Johnny Bones that the 'when' has been more of a slow progression.
Electronics pt1 - synthesizers and samplers
From the 70s onwards, synthesizers became increasingly practical to use in the studio and on stage. As we moved forward towards the end of the millennium, they became very cheaply-obtainable due to the advent of virtual instruments, to the point where by the early 2000s anyone with a computer could put together a whole electronic studio on their computer for less than the price of a second-hand guitar and amplifier. This increase in accessibility can be related to the increase in electronic sounds in music.
Having said that, If this was the only technological development, I'm not sure if it would have led to a sea change in the sound of music. A lot of rock groups were flavouring their songs with synthesizer since (to take an arbitrary point) the early 70s, and although a synth (or a sampler) can clearly make sounds that an electric guitar can't, someone sitting at a keyboard playing an electronic sound can be seen as something that's still part of rock tradition. There is one aspect where a sampler in particular can start to disrupt the dynamic of a rock band though : as it's possible to sample sounds or vocal phrases that catch the audience's attention in the same way as a singer would, the singer now has competition...
Electronics pt2 - sequencing and studio techniques
One thing about electronic instruments is you don't have to actually play them, and in fact, you can do more with them if you don't. Once you start using a sequencer, you can trigger sequences of notes that would be nearly impossible to play physically; you can program changes to multiple sound parameters that you wouldn't have enough hands to physically control; You can even get the machines to choose your notes for you. The up-side of this is that you can suddenly go way beyond what was possible with physical instruments. The flip side is that the 'live' aspect of the music has gone : even if you have the machines on stage, you may be still essentially just be triggering playback (note that in very recent years, Equipment such as the Ableton program has started to push things back the other way!)
As well as instruments, there are many production techniques (auto-tune, time-stretching, reverse reverbs, vocal chop-ups) that can be applied to greater effect when laying down a track in the studio than they can live, so this also shifts music away from being something that is played live on stage to something that's produced in a studio and played back on stage e.g. by a DJ.
DJ and hiphop/club culture
Also from the 70s and 80s came the rise of at least two musical movements that were both oriented around DJ culture - Hip Hop, based around DJs and MCs (and mirroring earlier developments in Jamaican music culture to a degree), and House / Techno music. Hip Hop started to use the turntable more as an instrument than a way of playing back a static track, while House / Techno DJs took advantage of the rhythmically precise nature of the electronic tracks to beat-match tracks together. In both these cases DJs had elevated themselves from agents of transmission to performers in their own right, providing a rival to the traditional instrumentalist rock-god.
At the start of the 90s, the worlds of dance and hip-hop music remained somewhat separate, arguably more cultually than musically. Over the next decade or two, producers have started to take advantage of the fact that hiphop and dance music are stylistically very compatible, and this has led to the development of a hip-hop/dance crossover genre that still seems to have some way to run.
The future? (Opinion - please Ignore)
As I mentioned before, part of the reason for instrumental performers being out of the limelight a bit is the fact that the current generation of electronic instruments and processes work so much better in the studio than live. That, in turn, is something that's likely to change, and as electronic instrument interfaces and processing algorithms evolve it's possible that things could go back to being more genuinely live and things might be in some ways a bit more like they used to be.
There is no set point when this happens, it's usually a slow progression of steady music of a new nature, at a time when the market for the "old" popular music gets saturated.
However, don't forget that bands like The Foo Fighters, Red Hot Chili Peppers, Jon Bon Jovi, etc.. Still do chart on a regular basis.