It depends on your meaning. 'By accident' and 'by chance' don't have exactly the same meaning.
If 'I ran into him' means 'I met him in the street', for example, you would be more likely to say 'by chance' in this situation. This means 'I happened to run into him' ie you hadn't arranged to meet, and you didn't expect to see him.
'By accident' is mainly used when you have done something wrong, but not deliberately. It is the opposite of on 'purpose'. So, if 'I ran into him' means, for example, that I physically banged into him during a football match, then you could say 'by accident'. This would mean that you didn't deliberately bump into him, or that you didn't do this 'on purpose'.