In a major boost for gay rights, the Carter administration has forbidden government officials from inquiring into the sexual habits of employes or individuals seeking most federal jobs.

The directive will be delivered to agency and department heads this week. It also requires the government to count, as work experience, service as an unpaid volunteer in homosexual-related civic projects, such as community task forces on problems of homosexuals, or service with a gay legal or medical clinic.

Federal agencies already take into account volunteer service in other community activiities when rating the experience of potential employes to determine their pay and grade level.

Alan K. Campbell, President Carter's chief adviser on the federal bureaucracy, signed the order Monday, although few federal officials know of its existence. Campbell and top White House aides consulted with federal personnel officials, legal experts and with leaders of the homosexual community.

The new order covers most federal agencies and departments that employ about 95 percent of the government's 2.7 million workers. Officials say the changes are in line with recent court rulings that have outlawed work-place discrimination against homosexuals, and/or unmarried persons living together.

It has been an unwritten practice in many federal agencies (and private firms) to check up on alleged homosexuals, and to deny them employment or promotion either on "moral" or security grounds.

The new order will make it illegal for agencies to inquire into nonjob-related sexual, social or other habits of employes.