Typically you can do it about 6 months in but it's best to make sure you are getting a lower interest rate 1st no since in refinancing if that is not happening or if you got the funds to pay of PMI if you happened to have that.
Now to sell after refinancing you may want to wait until you have built some equity in the home before you sell. But you will need to check with your lender just in case there's any policy on time. When you refinance your mortgage the amount you owe will increase so you need to make sure that amount doesn't seriously exceed how much you can sell your home for.
As long as you can pay back your lender and pay your other expenses at closes then you have the green light to sell. So key note in that...build that equity 1st. and that all depends on the area you live, schools, if it's building up etc.