How soon can a mortgage be refinanced?

You can refinance your mortgage anytime you want to. There is no minimum time before you can refinance.

That being said, you do need to be aware of any "prepayment penalties" or clauses. Some loans ( especially sub prime ) will have a prepayment penalty. If you refinance your existing loan before that pre payment period is over then you have to pay the prepayment penalty.

These penalties can be as much as six months worth of interest.

Check your original note to see if you have this penalty. If you do have a PPP then you need to weight the financial benefits of refinancing against the penalty. There are some cases where such a transaction still makes sense.