Over-watered plants attract fungus gnats to breed. Also keep decomposing organic matter away from your potted plants so they have nothing or less to feed on. Make sure plant soil is dry and decomposing organic matter is regulated. You can use a surface treatment to kill gnats. Also try using repellent that contains DEET.