I have had this problem the last few days. Very frustrating.
Executive summary: In brief, it was a hardware problem: I went to apple store, they check and as I was under the 1 year warranty they replaced my iphone 5.
Details:
Symptoms were strange and same as above: Siri and dictation did not work on the phone itself but did work with headphones. It appeared that neither Siri & dictation could not hear me (the wavy line did not move). The speakerphone also didn't work in that people could not hear me. However, Siri raise to speak worked, voice recording worked, etc. It seemed so bizarre that it could only be a software bug. But not.
Solution: I went to the apple store. They took the phone and checked it out. There was a hardware problem with one of the microphones. There is more than one microphone! One was broken.
There is the microphone on the bottom next to the speaker that makes sounds. This is the regular microphone one talks into. Then there is another microphone, a tiny one, on the back next to the camera. Apparently this one is for videos. Now most applicaitons just use the regular microphone but some applications use both. And Siri and dictation use both. And the little one was broken. Hardware problem. Phone was replaced.
Moral of the story: maybe it could be a software problem, but it can be hardware.