With only one minute left on the clock, Okazaki dived for a header on a cross from midfielder Hiroyuki Taniguchi and the ball hit the right post before bouncing into the Australian goal.
"I planned to go for it in the second half, thinking we will play in similar hot conditions in the Olympics. It was good that we scored a goal at the last moment," said Japan coach Yasuharu Sorimachi.
"Our next and last tune-up game is against powerhouses Argentina. I expect that we cannot play our usual game, but we will do our best before going to Beijing," he added.
Australia got off to a good start, exchanging quick passes to make the pace in the first 15 minutes, but the Japanese started to fight back. Japan had 16 shots on goal against four for Australia but it was the visitors who took the lead.
The Japanese defenders made an error, allowing forward Nikita Rukavytsya to take the ball. He sent it to fellow forward Archie Thompson, who struck home the opener in the 34th minute. Japan evened the score in the 41st minute when midfielder Shinji Kagawa quickly collected a pass from Takayuki Morimoto in the area.
"I must make an appeal before the Beijing Olympics, so I'm very happy that I scored a goal. Hopefully, I can go to the Olympics in my best form," said Kagawa.
In the Olympics next month, Japan will play Nigeria, the United States and the Netherlands in Group B, while Australia will meet Serbia, Argentina and Côte d'Ivoire in Group A. Earlier in the day, Japan also defeated Australia 3-0 in the women's tune-up game.