It did not say when the raid took place but said up to 10 of the attackers were believed to have been killed in Pakistani retaliatory fire.
Pakistan security forces killed at least eight to ten terrorists who launched cross-border attack at the check-posts of Pak Army in Bajaur Agency from Afghanistan, Inter Services Public Relations said.
Major General Asif Ghafoor tweeted on Monday that Pakistan was paying the price for a security vacuum on the Afghan side of the border.
The two security officials identified as captain Junaid Hafeez and Sepoy Raham were killed while four soldiers were also wounded in the attack.
The ISPR said that the attempt was effectively responded by Pakistan army as terrorists had to flee.
The anti-state Pakistani Taliban militant group claimed responsibility for plotting Monday's attack.
The injured militants managed to escape to the border areas. The attack came a week after unidentified gunmen shot and killed a Pakistani diplomat near his residence in the eastern Afghan city of Jalalabad.
Talking about the militant hideouts in a war-torn Afghanistan, General Ghafoor said: "It now requires the elimination of terrorist sanctuaries in Afghanistan and effective Afghan border security".