does a log transformation of the dependent variable affect autocorrelation? I have panel data and have used the xtserial command in Stata to test whether there is autocorrelation.
When I take the log of the dependent variable, the test shows that there is autocorrelation. When omitting the log transformation there is no autocorrelation.
I cannot see why this is the case?
Transformation of the dependent variable should have nothing to do with autocorrelation, right? 
 A: Transforming the data can change the p-value of a test statistic, and this in turn may change the decision you would take (accept/reject) the hypothesis. In your case, taking logs probably flattened down the data, giving you fewer outliers and possibly giving you a smaller variance, relative to the autocovariances of the data. 
Note that the impact of taking logs is not always to decrease a p-value and increase the chance of getting a significant result. Logs can have the opposite effect.
So here's the thing: why take logs? Your significance test is probably hoping for normally distributed data. If the logs make your data more normalesque, then go with the logs. If not, then not.
A: Because autocorrelation is correlation among two (overlapping) sets of residuals, this phenomenon can be understood in terms of correlation alone.  Although taking the residuals in a regression plays some role here, the chief cause of the effect is how the dependent variable changes when its logarithms are used in the regression.  This is something we can easily understand with a picture.
Consider the classic football-shaped cloud.  Correlation measures its scatter around its geometric spine, with values near $\pm 1$ corresponding to very little scatter around a straight midsection.  When this is a cloud of logarithms, you can obtain the original data--the "antilogs"--by exponentiating both coordinates.  Exponentiation hugely exaggerates the largest values.  This can draw the cloud out into two long lines, one horizontal and the other vertical. At the same time, any points with both coordinates moderately large can be blown so far away from most of the others that they control the correlation coefficient.
Here's a picture of such data with the logs on the left and the antilogs on the right.  Least-squares fits (whose slopes approximately equal the correlation coefficients) are shown as red lines.  Strong autocorrelation of the logs ($\rho=-0.7$) disappears in the original data ($\rho=0$).

It is possible for the correlations to completely reverse signs, too: play with the parameters in this R code to explore the possibilities.
require(MASS) # Exports mvrnorm()
set.seed(17)
#
# Create a scatterplot around (0,0) with correlation rho with a small 
# amount of outlying data around (2.5,2.5) with correlation 0.5.
#
rho <- -.8
e <- data.frame(rbind(
  mvrnorm(990, c(0,0), matrix(c(1,rho,rho,1),2)),
  mvrnorm(10, c(1,1)*2.5, matrix(c(1,.5,.5,1)/2,2))))
#
# Plot the data and their antilogs.
#
par(mfrow=c(1,2))
for (d in list(e, exp(e))) {
  d.range <- apply(d, 2, function(x) diff(range(x)))
  plot(d, asp=d.range[2]/d.range[1], cex=0.5, pch=19, col="#20202030",
       main=paste("Rho =", round(cor(d)[1,2], 2)))
  abline(lm(d), col="Maroon", lwd=2)
}

