I think the answer is just that it was a long shot plan he was hoping might work, but at the end after putting young Amelia to sleep he was having a lot of doubts, saying "silly me" to have thought he could "hang on" this way...from the transcript:
DOCTOR: It's funny. I thought if you could hear me, I could hang on
somehow. Silly me. Silly old Doctor. When you wake up, you'll have a
mum and dad, and you won't even remember me. Well, you'll remember me
a little. I'll be a story in your head. But that's okay. We're all
stories in the end.
Then at Amy's wedding when she remembered him fully and he did come back, he said he was surprised:
AMY: Okay, Doctor. Did I surprise you this time?
(The Doctor appears in top hat and tails.)
DOCTOR: Er, yeah. Completely astonished. Never expected that. How
lucky I happened to be wearing this old thing. Hello, everyone. I'm
Amy's imaginary friend. But I came anyway.