So you have an optical cable from the dvd player to receiver and when you select dvd you can hear the sound. That's good, the digital audio input is assigned to the dvd input.
Why do you select the cd input when trying to listen to a cd? The dvd player can play cds too. You shouldn't have to do anything to play a cd in the dvd player - just select the dvd input on the receiver.
Now, if you want to use the cd input for some reason and the dvd player has another digital audio out (most have at least one coax and one optical out), just connect that output to another digital audio input on the receiver and go into the receiver setup menu and assign that digital input to the cd input.
There is no reason to do this because the dvd player can play the cd without changing anything, but some people might do it to compare the optical output to the coax output or to make it easier for others in the house (press 'cd' to play cds and press 'dvd' to play dvds).