You go to an instructor who has a "try gun"
Or, you can play around with it yourself. Note that when you do this, there are some changes which are quick, easy and reversible... some are none of the above.
Let's take my Browning 425 as an example. I bought it new and shot it a bunch. While I broke targets well with it, the stock was a bit long and it had an annoying tendency to bash me in the face... often hard enough to draw blood and leave a goose-egg under my cheek-bone.
So, as a first step I took it to Kolar Arms in Racine, WI and had them do some minor fitting work. Basically, one of their stock-guys had me do a bunch of gun mounts and such, finally deciding to remove about 3/8" from the stock and slightly change the pitch. He also fitted a Pachmayr Decelerator recoil pad, which was much better than the OEM pad. While I was there, they also relieved the forcing cones.
I took it home and shot it a bunch. Better, but after enough shells it would still draw blood. I then tried all the easy stuff. I built the comb up with moleskin. I tried shimming the recoil pad top and/or bottom. I shot with a Past. I used ultra-light loads. I changed (for a while) how I mounted the gun. Most of the things made the problem no better, or slightly worse. By the end of it, I'd developed a flinch and my shooting started to nosedive.
Got a new gun -- an autoloader. Shot it often and well, and got rid of the flinch.
I finally decided that I was either going to make the 425 shoot for me, or I was going to sell it. Since I had tried adding height to the comb and that hadn't helped, I figured that going the other way would do the trick. However, removing wood (especially from my most expensive shotgun) was a daunting task. After the first shavings peeled up and I was committed, it got easier. A couple hours later, I'd removed about 1/8" from the comb and a bit of material from the left side, making a better fit with my face.
Since I had lowered the comb, I added a couple cardboard shims under the bottom screw on the recoil pad, to bring the POI back up a bit. I took the gun out, patterned it and shot it, and all was finally right with the world.
Now I'm experimenting with a homemade recoil-reducer in the hole for the stock bolt. Since the gun was quite muzzle-heavy, this has changed the balance point to just forward of the hinge-pin and although the gun is heavier, it handles more neutrally. The thing I'm not sure about its if I like the way the recoil feels, since the weight has the ability to move a bit (cusioned by springs front and rear).
Please note that all this stock fitting seems to be far more of an issue when using O/U or SxS shotguns. I've never had a significant issue shooting either pumps or autoloader (and I've used many types of each). Over/Unders are a different story. If they don't fit well, they can be truly miserable.
Even though my experience was lengthy and painful (literally), I'm glad that I went through it. I've now got a far better understanding of gun fit and how all the parts of the stock geometry work together.