From what I see about 5e Elves and Dwarves it seems like it depends but let's assume this situation:
Typical Tolkien-like structure of languages. What we have first is Dwarven and Elfish are alien. Those languages have no correlation to each other - Elfish borrowed some things from Welsh and Finnish, Dwarven - closer to Semitic family of languages.
To learn a language you need a lot time and it must be relevant to be ingrained in one's brain. Here are points that serve a foundation for it:
Children are flexible.
Any creature with human-like intelligence is interested in learning practical and useful things.
Kid would not learn obscure language if he has no mentor and practical need to learn it*. Also, consider case of feral childs - children who learn 'language' of their beastial 'parents'. I mean - if you give kid to be raised by wolves - when he grows, he will know Wolven (or die), you give kid to be raised by Dwarves - when he grows, he will know Dwarven. As a sidenote, feral children have major problem learning human language because concept of real spoken language is too alien for them when they passed flexible stage (it ends about 6years old if I'm not wrong...)
Special cases: Elf risen by dwarves will speak Elfish if:
This is a land of Dwarves occupied by Elven invaders and stripped from their native language and culture.
Dwarves and Elves have similar language in your setting.
Elves in your setting has something like 'genetic memory'.
Elves in your setting share global telepathic link.
Small Elven child has an intelligent item that speaks Elfish.
One of stepparents of young Elf is translator and/or diplomat who has to maintain contact with other elves.
There is a small community of Elves living alongside Dwarves.
P.S. After reading quiestion, I wondered: would male Elf raised by Dwarves develop facial hair due to cosmic laws of chaos and order. I have no answer to that, alas...
'* I lied here - actually kid can learn obscure language if he perceives it as something 'useful' (or abusable ^ ^) for a loooong time it takes you to learn that language. Bear in mind that kid's perception of 'useful' can be misguided or manipulated by his social environment and culture he was raised in. Also, in our age there is a complex system of strong forces that constantly try to attack perception and take it under control - marketing professionals, informational wars, propaganda, con artists, religious fanatics. I feel that in more 'natural' older times there would be less of those forces - for something like Europe Medieval there would be only be religion, shamanistic rituals, local beliefs about outerworld; othervise 'useful' mostly corresponds to 'survive' - get shelter, get warmth, get water, get food, stay sane and somewhat healthy. For a Forgotten Realm Dwarves hold I don't see any major forces that manipulates little elf to start to percieve Elvish as 'useful' so I shortcuted that to 'practical', if you pardon me ^ ^