Over 60 years ago Durbin and Watson suggested a testing procedure for assessing autocorrelation in regression relationships.The test is known to not work in the presence of lagged dependent variables, in which case Breusch-Godfrey test from the late 1970s applies. Any other known situations where the Durbin-Watson test should not be used?
The Durbin Watson test or
dwtest is useful for checking the presence of first-order autocorrelation only. However, your time series might have higher-order autocorrelations as well. In that case Breusch-Godfrey test is used.
A similar argument holds true when you are working on a regression problem that doesn't involve a time series. In that case we can apply the same test to check the correlation in residuals.