Welcome to Android Central! Does this happen on both wi-fi and mobile data? If it's only on mobile data, then is the cell signal very weak? Weak signal makes the phone work harder to maintain a connection, which causes the phone to heat up.
Does it happen with casual browsing, or are you watching online videos? Watching videos will probably make the phone heat up more, since it's more processor intensive.