Jan 12 (Reuters) - Australian shares closed higher on Wednesday to mark their first gain this week, as energy stocks led gains after a surge in oil prices, while Afterpay jumped after its takeover by Block got a final approval.

The S&P/ASX 200 index ended 0.66% higher at 7,438.9 after falling for two straight sessions.

Afterpay, one of the world's top buy-now-pay-later firms, climbed as much as 6.8%, its best day since Aug. 3, after its mega-buyout by payments firm Block got a nod from the Bank of Spain, making the deal fully unconditional.

Woodside Petroleum and Santos, Australia's biggest oil and gas firms, climbed 4.1% and 3.3%, respectively, lifting the broader energy index nearly 3% higher.

Oil prices extended big gains after the Federal Reserve chief signalled that the central bank may raise rates more slowly than expected, which should support oil demand in the near term.

The highly anticipated U.S. inflation data, which is running well above the Fed's 2% target, later this week will be key for investors as they look for guidance on whether the Fed may have to hasten the pace of its interest rate hikes.

If inflation rate is more than market expectations, then markets "will start to panic that it (rate hikes) might happen even faster than expected," said Mathan Somasundaram, chief operating officer at Deep Data Analytics.

Quicker rate hikes by the Fed may cause global funding rates to rise, costing Australian banks more to borrow despite the Reserve Bank of Australia not raising rates itself he added.

Gold stocks also climbed as much as 3.4%, its sharpest gain since Dec. 17, on firmer bullion prices.

New Zealand's benchmark S&P/NZX 50 index fell 0.2% to 12,804.48. The top percentage loser was carpet maker Bremworth Ltd, with a 3.9% drop. (Reporting by Navya Mittal; editing by Uttaresh.V)