One of my boars (Yossi) also sometimes makes a noise, indicating discomfort, when expelling a caecotroph. As with your pig, it doesn't happen when peeing or expelling 'normal' poo pellets or at any other time.
Yossi's 3 yrs old so initially I wondered if it could perhaps be the start of impaction problems, but so far it hasn't developed into that (i.e. the pellets are properly formed and nothing actually gets stuck!) In Yossi's case I don't think it's arthritis related as it happens only when actually expelling - after making the noise he retrieves the pellet straight away, no problem. Saying that though, it could still perhaps be muscle related? Anyway Yossi's been doing this for a few months now but most days he's fine and apparently pain-free.
My Vet thought it could be due to a lack of fibre. As Yossi always gets unlimited good quality hay already, she suggested that I increase his fibre intake by adding a high fibre supplement/probiotic to his veg - she suggested Protexin Pro Fibre for Rabbits. (I didn't try the Protexin one but I do give a tiny sprinkle of probiotic most days).
Yossi very rarely drinks for himself and I think this may cause or contribute to this problem, so I syringe-feed him water to supplement his daily intake and make sure he's not dehydrated. I figure that, as well as helping to keep the caecotrophs well formed and not too dry/hard, it may also help with the production of mucous/natural lubrication needed to actually expel these pellets with ease.
I've also found that Yossi seems much better when I follow a strict veg diet for him, like Ratewatchers. I don't know if it's the ca : ph ratio which helps or if it's something else, but when I follow it meticulously his 'episodes' are much less frequent.
Basically as long as I watch his veg and make sure he gets plenty of water, then the problem happens quite rarely. On the very rare occasions that he seems particularly bad, i.e. more than 1 painful episode in a day, then I'll give him some Metacam which seems to help.
I'd love to find out what is actually causing this problem. I'm seriously considering trying Yossi on Cystease, thinking that glucosamine may well help to reduce any possible inflammation in the intestines/caecum/colon or wherever.
Hope you manage to find a solution for Sam very soon. I agree that ruling out stones is important (I did the same for Yossi). Has the Vet tested Sam's urine at all, to test for infection or the presence of blood? If your Vet thinks there is an infection in his bladder/urinary tract and wants to keep him on antibiotics, then perhaps ask to try Septrin, as many consider this to be more effective than Baytril in treating UTIs etc. It's also worth asking for an anti-inflammatory too (i.e. Rimadyl or Metacam) as this help will ease any pain.
Good luck x