This is not something that you normally have to learn unless you are learning English as a second language (ESL). Alas poor ESL students have to learn vast amounts of nonsense called rules of the language. The pronunciation of 'ed' for 'past time sense verbs' is a case in point.
The Rule
1. 'ed' is pronounced /d/ as a 'd' after voiced sounds. eg after b, g, z, mooned, loved
2. 'ed' is pronounced /t/ as a 't' after voiceless sounds. eg after p, k, s, stiffed, pecked
3. 'ed' is pronounced /Id/ as a 'i' plus a 'd' after 't' and 'd' sounds. eg wanted, needed
The Rule sounds great and straightforward if you don't think about it too much. If you are an ESL student then all you have to do when speaking in 'past time sense' is to stop speaking determine if the sound before the 'ed' is voiced or voiceless choose the correct pronunciation and then continue speaking. What a load of nonsense.
The first problem is the fine-linguistic-line of voiced and voiceless. There is a simple test you can use to test for voiced and unvoiced; place your hand on your throat and fell for vibration. A vibration means voiced and no vibration means unvoiced. Since you already have the answer here to check against then maybe it worked and you're thinking, "amazing". Now try this - make the voiced sounds without causing any vibration. 'g' works without vibration while 'b' and 'l' are marginal. Try voicing the voiceless sounds; you should be able to get a vibration out of 'p' and 'k' but the others are also possible.
Once you have the sounds working the wrong way put them into some words. Are the words still intelligible and valid pronunciations (or accents). Yes, they are. Voiced and voiceless sounds are subjective, and will vary between individuals. Furthermore voiced and voiceless is not some simple binary relationship but a whole analogue scale of variation. If you make further observations of your own speaking you will find that the voicing of sounds will vary in different words, sentences and emphasis.
So as an Anglophile, how do we determine the pronunciation of the 'ed', if the voiced and voiceless test is invalid. Before answering that let's look at 't' and 'd'. They are related sounds or you could even say they are the same sound separated into two sounds. You can make them by gently pressing you tongue against the top of your mouth and releasing a small pressure of air each in a slightly different controlled manner (with or without any voicing).
With this experiment you will find that the difference between the two isn't as linguists say, a matter of voicing but is more a matter of how you can control the flow of air with your tongue. The tongue is pretty agile but when we speak the tongue is not always in a good position to make the next sound perfectly correct so what happens is that each sound is distorted by the sound before it as the tongue tries to wrap itself around the mouth. A good tongue twister (not a simple alliteration) will total destroy sounds until you slow to an unnatural speed or exercise you tongue to cope with the quick change.
It doesn't matter what the voicing of the sound before the 'ed' because that voicing is on an analogue scale and so is the voicing on the 'ed' itself. 'ed' is always pronounced /d/ as a 'd' before sounds other than itself /t/d/. How it is pronounced and how it sounds when it comes out are two different things. We pronounce it as /d/ but sometimes it comes out sounding like a /t/, this is really no big deal. Try reversing some pronunciations without undue emphasis and you will see how irrelevant this is to the language.
The fact that 'ed' comes out sounding like a 't' sometimes is noted in English spelling where the pronunciation of the word sounded better when it was pronounced as a 't'. For example in English the past of 'dream' is 'dreamt' (note that the long vowel sound becomes a short vowel sound in the past form). 'Dreamt' for anyone with an ear for music, poetry or language is a much sweater sound than 'dreamed'. You can see that according to the so called 'Rule' /m/ must be followed by a /d/ and yet 'dreamt' with a /t/ rolls off the tongue much easier than 'dreamed' with a /d/.
The last consideration is when a 'ed' follows a a /t/d/ sound. In fact this is the only time that we are not lazy in shortening the pronunciation of the 'ed' which obviously is /ed/. Repeating the same sound in English words is not standard and the full pronunciation with the /e/ is necessary. The /Id/ pronunciation is absurd and anyone trying to speak like that sounds like and idiot. A more moderate pronunciation would be the ugly /ǝd/ as a grunt plus a 'd' after. The grunt /ǝ/ is the natural decay of a vowel when we are rushed or don't care if we sound uneducated or are too arrogant or ignorant to know the difference between correct and garbled pronunciation.
I said that /ed/ is the correct pronunciation in all cases then what about /d/. English pronunciation has been smoothed out over time and as explained, in most cases /ed/ has been smoothed to /d/. This pattern has even carried through into the USA dialects where in most cases the smoothing out of pronunciation has been removed.
'ed' is pronounced /ed/. The /ed/ pronunciation is smoothed out to /d/ in words where it is not a repeated sound. In some words when we pronounce /d/ it will end up sounding like a /t/, there is not need to deliberate mispronounce the word with a /t/ especially with emphasis (missed and mist are different words and can be pronounced differently). Some English words have been changed to a /t/ through spelling, these words sound sweater (and less harsh) than they do with a /d/. - Alan