Originally Posted by
flatlander
Give the second passport details on checkin for the return flight. It's easy to replace passport details at checkin, I did this most recently when I had renewed my passport a week before checkin and had entered passport details of the preceding passport months before checkin. In addition if the reason for entering on the second passport is residency and visa related, BA will remind you by asking for a visa or nationality you don't have in the first passport.
NB the OP's question was slightly different: he wants to fly from the UK to country X, leaving the UK on passport A and arriving in country X at the end of the same flight using passport B. You can't replace passport details *during* a flight AFAIK (even if you have on-board wifi).
But as others have said, use the passport you're leaving the UK with, as that's the one you'll show at checkin and which may be checked against the APIS details on the booking (I don't know if they even do that - APIS data is used to check against no-fly lists, which is done separately).