Nobody: it was a bootstrap paradox.
From the episode Let's Kill Hitler:
DOCTOR: Mels. Short for ...
MELS: Melody.
AMY: Yeah. I named my daughter after her.
DOCTOR: You named your daughter after your daughter.
Amy named her baby daughter after the girl Mels, whom she'd met before her daughter was born (in Amy's timeline), but who was in fact her daughter.
So Amy got the name from Mels, who was given it by Amy, who got it from Mels, who ...
That's the thing with paradoxes: there's no clear answer.
There's an interesting blog post
here which analyses how common the first name Melody was and how strange it would be for Amy and Rory to come up with such a name (the answer: not very). Sorry for the massive quote:
Melody is currently (2010 figures) sitting at #198 in the US girls’ charts. It’s been climbing steadily for the last decade – it was #436 in 1999, jumped in 2000, and continues to rise. On a longer scale, it’s a keeper: Melody hasn’t been out of the top 1000 since 1942. Its heyday was the late 1950s through to middle 1960s, reaching an all-time usage high in 1960: 479 Melodies in every million baby girls.
The last Melody spike is about two generations ago – assuming a 25-year generation gap (it’s widened slightly over time, but it’s a round figure) the adult Melodies are going to start becoming grandmothers right about now.
People don’t tend to give their children names of their own generation. When naming a child, people want something that sounds interesting and fresh, not something that conjures a mental image of name-calling and school registers. [...] Sure enough, Melody goes down and down and down after the 1960 spike, and its absolute nadir is in the mid-1980s – just about when, with a 25-year generation, the 1960 Melodies would be naming their own children.
Names from one’s parents’ generation, though, are sometimes fair game, especially if they’re known-but-not-common. They aren’t depressingly familiar, but you heard them around somewhere. And they’ve had a generation out of the public eye to recover, as it were. Three generations apart, the effect can be even more pronounced, as people jump on their grandparents’ names that are just so delightfully vintage and retro now. (Florence, Faith, Lacey, Stanley and Arthur are all currently in the England and Wales top hundred.) Depending on the age of Amy’s parents and grandparents, we could be seeing either the two-generation or three-generation cycle in effect – remember, it’s been charting in the US since 1942.
So it’s actually pretty plausible that Amy would have come up with Melody from somewhere, if she had childhood memories of an adult Melody – perhaps even her geography teacher – and nicely poised between trendy and zany, which seems pretty in line with Amy’s traditional but not too traditional character. (White wedding, but didn’t change her name.)
This isn’t the first time Doctor Who, and specifically Stephen Moffat, have proven surprisingly astute in their baby-naming choices. Way back in 2008, Moffat’s two-parter Silence in the Library and Forest of the Dead saw then-companion Donna Noble uploaded into a simulation wherein she married another uploaded personality and had little simulated babies whom she named Joshua and Ellie. That year in England and Wales, Joshua was #5 on the boys’ charts and Ellie #16 on the girls’. Bang on trend.