For the last 20 years the civilian National Aeronautics and Space Administration served itself and the scientific and technological communities almost exclusively.

No longer. NASA is about to begin serving a big new customer, a federal agency almost 40 times its size: the Department of Defense. When the space shuttle Columbia makes its fourth and last test flight next month, its cargo will be a secret Pentagon infrared laser whose invisible light can detect the rocket exhausts of missiles on their way to distant targets.

The trucking into space of the Pentagon's early warning laser spotlights what some observers of the civilian space agency say is a dangerous new trend.

In the years ahead, NASA will be dealing more and more with the Pentagon. More space agency business will be shrouded in secrecy, more of its missions will be classified and more of its research and development will have a military instead of a civilian application.

One sign that the space agency is being "militarized" is in the number of Air Force personnel now on active duty at NASA. There are eight Air Force officers assigned to NASA headquarters in Washington, 60 to the Kennedy Space Center at Cape Canaveral and 66, plus 22 Air Force civilian employes, at the Johnson Space Center in Houston.

NASA's top management has taken on a distinctive "blue-suit look." Head of the new Office of Space Transportation Systems is Air Force Maj. Gen. James A. Abrahamson. His executive assistant is Air Force Col. Joseph Rougeau. The head of external relations is retired Air Force general Frank Simokaitis. NASA deputy administrator is Dr. Hans Mark, a former secretary of the Air Force.

Of the first 44 shuttle flights NASA will make through 1986, 13 will be flown solely for the Pentagon. Of the 234 flights tentatively scheduled through 1994, according to a report released this week by the General Accounting Office, at least 114, or 48 percent, will be flown exclusively for the military.

In the past the Pentagon rarely flew even an experimental instrument on a space agency spacecraft and it was not supposed to be involved in more than 30 percent of the space agency's shuttle flights.

In a report prepared for Sen. William Proxmire (D-Wis.), senior Democrat on the Appropriations Committee, the GAO concluded that the space agency earmarked for the Pentagon almost 25 percent of the $3.47 billion it will spend on the shuttle in fiscal 1983. This includes two of 10 shuttle flights in fiscal 1984 and four of 13 flights in fiscal 1985.

"This is bad news for those who are concerned over cutbacks in NASA's space science activities," Proxmire said earlier this week. "Unless there is a dramatic change in current efforts to reduce federal spending, it means that more and more of each NASA budget will be spent on defense-related activities and less and less will be spent on civilian science."

What concerns Proxmire even more than the Pentagon's inroads into space agency business is the way the Pentagon has managed to avoid paying for it. The cost to the United States to develop and produce the first two space shuttles (Enterprise and Columbia) and test-fly Columbia four times is $9.9 billion. NASA will pick up the entire tab. The Pentagon's share of the shuttle development and test flight bill is zero.

Of the $15 billion it will cost to build and supply four flight models of the shuttle, the Pentagon's share is $2.4 billion. Most of that is for a shuttle launch facility at California's Vandenberg Air Force Base where 47 of the planned 70 flights at Vandenberg will be for the Air Force.

One of the major new improvements to be made to the shuttle is development of a lightweight casing for its two solid rocket engines that will let the shuttle carry 5,500 more pounds of payload into orbit. The $250 million improvement bill is being picked up by NASA even though the development will benefit the Pentagon, whose payloads are far heavier than anything NASA and the civilian shuttle users will fly.

Even when the Pentagon flies an instrument or satellite on the shuttle, it will do so at a bargain rate no other shuttle customer is being offered. Civilian shuttle users are being charged $18 million a flight through 1986 when shuttle user fees will be renegotiated. Not the Pentagon. Whenever the Pentagon flies on the shuttle through 1986, the use fee will be $12.2 million, a discount of 32 percent.

"It's clear to me that the Pentagon is getting a free ride on the space shuttle," Sen. Harrison H. (Jack) Schmitt (R-N.M.), chairman of the Senate subcommittee on space, said in an interview. "I think the time has come for the Defense Department to start paying for its share of that ride," the former astronaut added.

One thing the Pentagon is already paying for is security. The Pentagon is spending $26 million to modify the firing room (launch control center) at Cape Canaveral and $47 million to modify the Mission Control Center in Houston to safeguard the secrecy of its shuttle missions. The two-story Mission Control Center soon will have a third story with copper floors and copper ceilings to prevent any communications between the Air Force officers on the ground and astronauts in space from leaking to the air outside the building.

Even the routine air-to-ground chatter between shuttle astronauts and Mission Control will change when the Pentagon flies its payloads in space. More and more conversations will be private, fewer in-flight television broadcasts will be aired and the handling of Pentagon payloads will not be discussed over the public air-to-ground radio channel. Even the choice of astronauts will undergo a change.

"We will use astronauts on our shuttle missions from the regular NASA corps," Air Force Brig. Gen. Joseph Mirth said not long ago, "but only those with a military background."

The space agency has begun to involve itself with the Pentagon on more than just the space shuttle. NASA is turning over more time in its wind tunnels to the testing of military aircraft and is placing more emphasis on the military aspects of its aeronautical research at the expense of its civilian research.

The most controversial of NASA's plans to involve itself more with the military is its plan to seek more military contracts for the Jet Propulsion Laboratory, its Pasadena brainchild that designed, built and directed the Voyager spacecraft that explored the planets Jupiter and Saturn in the last four years.

There was a time when JPL did no military research. In the last year, it has negotiated contracts with the Air Force, Army and Navy and has made it a goal to do between one-fourth and one-third of its research for the Pentagon.

Among the projects JPL has taken on for the Pentagon are automated reconnaissance satellites that maintain themselves in orbit for years at a time, that communicate with Earth at unheard of speed and precision and that keep watch on the seven seas with radar the way cameras now do over land. JPL's first assignment from the Army is how to automate the battlefield. In a word, put robots into tanks instead of men.

"The trouble with this work is that a lot of it is classified, which means you can't tell your wife and kids what you're doing anymore," said one JPL official who insisted on being nameless. "The good thing is that it keeps the team sharp, it keeps the lab's skills intact while the space program slackens."

To hear NASA Administrator James M. Beggs tell it, the space agency must take on more work for the Pentagon if it is going to survive the rough seas of the Ronald Reagan budget years. Beggs also insists that NASA's expertise is essential if the United States is to maintain superiority over the Soviet Union.

"You don't just set an aircraft model in any wind tunnel and out comes a lot of numbers and somebody just crunches them," Beggs said in an interview. "The plain facts are, you need the NASA technical guys working our wind tunnels to solve the problems that come out of it, whether they be military or civilian aircraft."

As for the Pentagon paying more of its share for the ride it gets from NASA, Beggs responds a little differently.

"The other part of this has to do with the question of whether we're bending over too far backwards in accommodating the military on things like the shuttle," Beggs said.

"I guess I come out somewhere in the middle of the people who want to charge them for everything and those who want them to have a free ride." Pausing, Beggs said: "We have considered raising the price to the military and are in active discussion as to how that can be done."