Depending on what type of 2 pair you have its not always the same. Its also about the plaer your against. top 2 being AK on a flop of AK7 betting pot will get you alot of folds. Betting pot on top 2 of 78s on a 782 flop makes more sense as they can have a over pair to play you with.
As for running into a set, there is really nothing you can do to avoid it. I should not happen often and it hurts but unless your playing deep stacks its almost inpossable to get away from top 2. If the other guy is not crazy and is willing to put 125BB into the pot against your top 2 pair then you need to consider your behind a set.