To get rid of drain flies create a drain fly trap using a glass with about a 1/4 cup of apple cider vinegar and cover the glass with plastic wrap and poke holes in the plastic wrap.
Be sure to secure the plastic wrap to the glass with a rubber band and then set the trap near the drain where the drain flies are.
Apple Cider Vinegar as well as plain vinegar can kill drain flies. The trap will catch the drain flies as they fly down into the glass and then drown in the apple cider vinegar.
Once you get rid of the drain flies be sure to clean your drains out of any organic material since the drain flies are attracted to organic material in your drains.
Clear out your drains and then pour some baking soda down your drain and then slowly pour some vinegar down the drain until it starts bubbling or fizzing.
Allow the vinegar and baking soda to sit in the drain for an hour to kill the drain fly eggs and clean your drain.
Then after an hour pour some boiling hot water down the drain to wash it away.
Keep doing that about once per week and you should be able to keep the drain flies from coming back.