The Irish twice took the lead through Sean Murray and Alan Sothern before being pegged back by Pakistan.
Almost constant Pakistan pressure was rewarded when Abu Mahmood levelled from a penalty corner to make it 2-2.
Ireland counter-attacked in the 57th minute for O'Donoghue to score the decisive goal from another set-piece.
Earlier, Murray converted a brilliant opener in the 11th minute when he connected with John Jackson's cross and sent a first-time shot into the roof of the net.
Aleem Muhammed Bilal equalised from the penalty-spot in the 17th minute and within 60 seconds of the start of the second half, Alan Sothern made it 2-1 with a first-time deflection.
Mahmood equalised with 14 minutes remaining before O'Donoghue's late winner.
The sides drew 2-2 in Thursday's opening game and will meet again on Sunday (14:00 BST) as the Irish continue their preparations for the World League semi-finals in Johannesburg.
Next month's South African tournament doubles up as the main qualifying tournament for next year's World Cup.
Later this month, Ireland will play against Germany, Spain and Austria at the Hamburg Masters which takes place from 22-25 June.
A late goal by Shane O'Donoghue sealed a 3-2 win for Ireland men's hockey team over Pakistan in the second game of the three-match series at Lisnagarvey.