I used pex to plumb my bathroom and now have water coming out the shower head when filling the tub
Sounds like you used PEX to run from the mixer valve to the tub spout.  Replace the PEX that goes from the mixer to the spout with copper.  You are getting a bypass to the shower because the PEX from the mixer to the spout cannot handle the flow without backing up to the shower head.  PEX has a slightly smaller i.d. than copper.