while I did my homework.
This implies that I listened to music at the same time I was doing my homework. The actions were simultaneous.
when I'd done my homework.
This implies that I listened to music after I had finished my homework. The homework was completed before the listening began.