They're both correct. But I think the first one is more elegant and clear.
Keeping "met her" and "by chance" close together in the sentence reflects the fact that the meeting was by chance and not something else. Also, the word "by" can mean "next to" or "beside". I could say "I met her at the cinema by the railway station". So saying "he met her at a dinner party by chance" sounds a little like that. Not enough like it to confuse anyone as to the meaning (no-one would say "So, she was standing next to a guy called Chance?") but enough to make it less elegant.