If no app works with the mic check that the mic is not 'disallowed'…
Settings app > Privacy > Microphone. See if any apps are disabled. The system apps do not appear in here, however it is worth testing any third party apps with the mic too.
Where did you buy it from?
If it's new a trip to an Apple store could help. I suspect they may reinstall the phone OS as a test, so I'd suggest you back up the device in iTunes or via iCloud. Once that is complete, you can reset it to factory state either via iTunes on a Mac or PC, or within the settings app > General > reset > erase all content. That will put it back to a default state.
If the issue still exists it suggests it could be a hardware fault, in which case an Apple store may be able to repair/ replace it.