Like Nova said, after you finish your battle with Keta for the second time, you'll be able to receive access to purifying your Shadow Pokemon.
From there, there are two ways to do it. One way is to go to Purity Forest once your Shadow Pokemon heart gauge is fully open to you where you'll talk to the old lady to purify it. The other way is by placing your Shadow Pokemon in the Purify Chamber, where you surround the Shadow Pokemon with regular mons in order to purify it. Once you surround the Shadow Pokemon, you'll have to walk around for a certain point til it will be ready to be purified.