Sounds like the B string didn't get "set" correctly in the hole/pin.
I'd look in there with a mirror and see what it looks like.
You can also loosen the string and give it a good pull to see if it sets then tune back up.
If the string is set correctly, it should stay in tune unless your new string was a lemon...which is doubtful, but could happen.