Sometimes I found that writing just "J. Doe" may lead, in a justified line with few words, to a big space between the initial and the surname. Using
J.\,Doe looks ok but I would like to know if there is a general rule for spacing between initials and surnames.
As often in typography, this depends a lot on your own taste. When you write, "sometimes I found that [...] a big space", you already got your answer. You should reduce the space with kerning, horizontal correction or, easiest way, a smaller space like
The reason for the "too big space" is the dot after your abbreviation. The big white space above this symbol is sometimes distracting. That's why many abbreviations which have to be separated are typeset with a half space. In German e.g. we have
The space after "J." is mandatory in my eyes, as you would set a space after "John" too. However, there is no international standard for this and for example in Switzerland, they often leave it off. E.g. "St.Gallen" on traffic signs. In Germany, the standard DIN 5008:2011-04 (chapter 5 page 10) requires a protected space
For a reference: F. Fossmann and R. de Jong write their initials with a half space in their book "Detailtypografie" and also recommend that on page 126. They are using round about 25 % of the DTP-em-dash or 20 % of the standard em-dash.
The last point would be the question if a line break would be acceptable.
In conclusion: I think
I usually use
to create an "unbreakable space", keeping the space fixed even in justified paragraphs and preventing line breaks.
This is also useful after abbreviations like e.g., i.e. and so on, where Latex thinks of the dot as the end of a sentence and adds too much space after the dot.