You didn't say what you have attempted so here's what I'm thinking...
Perhaps there is a build-up of dust inside it? (compressed air helps)
Do other headphones work?
Have you restarted the phone in case it's a software glitch?
It may or may not need hardware repair.