Following commissioning at Melbourne on 17 June 1942, HMAS Castlemaine proceeded to Sydney for working-up exercises, after which she began operations escorting convoys between Sydney and Melbourne. On the night of 11 August 1942, a collision with a Manly ferry in Sydney Harbour put her in the dockyard for seven days.
On 26 August 1942, she departed Sydney for Darwin, but was ordered to escort convoys between Townsville and Port Moresby. On 29 September 1942, she departed Port Moresby for Darwin, arriving on 5 October.
On 6 November, with a Dutch army officer and four war correspondents, one being Damien Parer, she proceeded to East Timor from where, after embarking soldiers and refugees during the night of 7/8 November, she returned to Darwin.
In November 1942, plans were made to relieve the Australian 2/2nd Independent Company, operating as a guerrilla force in Japanese-occupied Timor. HMAS Armidale, (another corvette), HMAS Castlemaine and HMAS Kuru (a former NT patrol vessel) were to run into Betano Bay on the night of 30 November/1 December, land Dutch troops and withdraw Portuguese refugees.
Another run on the night of 4/5 December would withdraw the 2/2nd Independent Company. HMAS Kuru sailed on 28 November for Betano, scheduled to arrive two hours before the corvettes, land stores and embark refugees for HMAS Castlemaine and land troops from HMAS Armidale. Then HMAS Kuru was to pick up wounded troops and take them out to HMAS Armidale before returning for her own passengers.
The corvettes left Darwin in the early hours of 29 November. En route they were attacked, by a single aircraft and later twice by bombers, but each time escaped unharmed. They were delayed but reached Betano at 0330 hours on 1 December. Meanwhile HMAS Kuru had embarked 77 refugees and one soldier, and, unable to wait for the delayed corvettes, had sailed for Darwin some hours earlier.
Lt Cmdr PJ Sullivan in HMAS Castlemaine ascertained Kuru was not present and sailed, meeting up 70 miles from Timor. Kuru‘s passengers were transferred to Castlemaine, which then searched for a missing aircraft before returning to Darwin. NOIC Darwin ordered HMAS Kuru and HMAS Armidale to sail back to Betano and land their troops, but en route HMAS Armidale was sunk by Japanese aircraft on 1 December 1942, with the tragic loss of two-thirds of the 149 people on board.
HMAS Castlemaine resumed escort duty on the Darwin-Thursday Island route. On 15 and 16 December 1942, her convoy bound westward to Darwin was attacked by Japanese aircraft. S.S. Period sustained a direct hit, killing four and wounding six members of her crew. The air attacks on the convoy were repulsed by HMAS Castlemaine‘s anti-aircraft fire.
On 19 March 1943, while escorting SS Babinda with RAAF personnel and supplies to Milingimbi in Arnhem Land, Castlemaine went aground in an unsurveyed channel. After unsuccessful efforts to free the vessel, she finally refloated with the tide on 21 March, with a fractured Asdic dome and sand abbrasion to a propellor. On 2 January 1943 HMAS Castlemaine arrived at Port Moresby escorting the troopship Van Heemskerk from Merauke. Until July 1943 she was engaged escorting merchant shipping between Darwin, Thursday Island and the Wyndham region.
On 20 July 1943 she returned to Sydney after an absence of 327 days, a period of almost unbroken seagoing service. Since commissioning, the corvette had steamed 31,000 miles. Refit kept her in dockyard hands until the end of August 1943.
Commencing with her departure from Sydney on 27 August, Castlemaine was engaged escorting convoys between Sydney and Brisbane, and Sydney and Melbourne, until 12 November 1943. On 28 November she proceeded to Townsville, and performed a number of escort voyages in the North Eastern Area between North Queensland ports and New Guinea.
On 23 March 1944 she transferred to the control of the Naval Officer-in-Charge, New Guinea. In New Guinea Castlemaine made numerous trips from Milne Bay and Langemak Bay, near Finschhafen.
The ship performed escort duties and transported supplies and personnel to Buna, Lae, Finschhafen, Saidor and Madang. She also escorted convoys to Cape Gloucester in New Britain, Seaddler Harbour on Manus Island, and Hollandia (now Jayapura), northern New Guinea.
On 11 June 1944, Castlemaine left Milne Bay, and via Brisbane and Sydney, arrived in Adelaide for her annual refit, having covered nearly 70,500 miles. On 2 August 1944 she departed Adelaide for Fremantle, then returned to Darwin on 20 August 1944. She had now circumnavigated mainland Australia.
At Darwin she was allocated service with a survey unit charting the Scott Reef-Browse Island area. Apart for a visit to Fremantle (24 February to 22 March 1945) HMAS Castlemaine performed survey duties for one year around Darwin and the Kimberley region.
The Pacific War ended on 15 August 1945, and on 16 August Castlemaine was sent to Morotai, arriving 19 August. She then reached Subic Bay (Philippines) on 24 August. She joined a newly formed RAN minesweeping flotilla consisting of eight ships, and on 27 August 1945 proceeded to Hong Kong.
Her flotilla was under the overall command of Rear Admiral Harcourt RN, who was tasked with the re-occupation of Hong Kong. Minesweeping operations commenced on 29 August 1945. After sweeping was completed on 30th August, Rear Admiral Harcourt RN entered the harbour on board HMS Swiftsure and formally reclaimed the colony.
HMAS Castlemaine and her flotilla were employed on patrols, destroying Japanese suicide craft and small enemy craft until the end of September 1945. On 3 October her flotilla was redeployed on mine clearance operations in the Hong Kong area.
On 14 October 1945, HMAS Castlemaine and other ships in her flotilla left Hong Kong for Australia, via Morotai and Thursday Island. HMAS Castlemaine arrived in Melbourne on 16 November 1945. She paid off on 16 December having steamed 117,000 miles and 13,000 hours under way on war service.