I always use the German rail site webpage to check out times for any train trip in Europe. Thanks to whomever gave me that tip here on the forum years ago.
https://www.bahn.com/i/view/index.shtml You can see there is a good choice of trains to Pamplona from Barcelona.
Public transportation is so good in Spain that you can really get pretty much anywhere in a reasonable time, but if you haven't bought your tickets yet (and if you aren't planning on spending time visiting Barcelona), I think going into Madrid is slightly easier for getting to Pamplona. You can, in fact, get a bus to Pamplona right from the Madrid Airport. And it may also be easier for getting back to from Santiago.
This thread has info on the bus from Pamplona to SJPP.
https://www.caminodesantiago.me/community/threads/getting-to-sjpdp-from-pamplona.52326/
Now, I know you didn't ask about this, but just in case it might help others who are planning a trip, adding the internal legs (Madrid to Pamplona and Santiago to Madrid) to your round trip international ticket may be not much more expensive than the round trip ticket into Madrid, at least if you are flying on Iberia or a One World partner like American or British Airways. Check the "multi city" option when searching for flights if you want to check it out. Barcelona to Pamplona involves going back to Madrid, so if you want to fly, you should definitely choose the Madrid point of arrival in Spain. I have done this for years now, and it really makes the travel much easier. This year I am starting in Almería and will fly into Madrid, have a few hours in the airport, fly to Almería, and be there by 1 pm. Train options would have gotten me in to Almería at 9:30 that night. Coming home from Santiago is also easy. Early morning flight to Madrid gets there in time for most US-bound flights.
Buen camino, and safe travels, Laurie