This is the relevant 'legislation' for NSW and I believe at least Vic is worded the same.
126 Keeping a safe distance behind vehicles
A driver must drive a sufficient distance behind a vehicle travelling in front of the driver so the driver can, if necessary, stop safely to avoid a collision with the vehicle.
Maximum penalty: 20 penalty units.