In the original series the input of real scientists was quite ad hoc. By Next Generation it became a permanent role.
When Gene Roddenberry developed the original series he wanted to make sure that the science was fairly credible. For example, he spoke to a number of scientists and engineers at the Jet Propulsion Laboratory in Pasadena, California � the NASA facility that does all of the unmanned probes to the planets. He also spoke to scientists at The Rand Corporation - a think tank in Santa Monica that did a lot of work for the airforce after World War Two, looking at the future of military technology. So it was a little ad hoc in the early days.
With Next Generation, it became clear that the audience in the 1980s and 1990s was a lot more technically sophisticated than the television audience in the 1960s. Gene realised that it would be a good idea to have somebody permanently available to handle technical issues in every script. I think that was the third or fourth season of Next Generation.