Companies adjusting to accounting-rule changes in the U.S. are running into a problem: There aren’t enough accountants to go around.

Health-products company Johnson & Johnson took six months last year to fill an open position for a junior-level accountant in its financial-compliance department, a delay that annoyed Stephen Rivera, a senior director.

“It’s very difficult to find qualified people,” he said. “The big accounting firms are taking them all.”

Amid accounting changes to the Generally Accepted Accounting Principles that govern U.S. financial reporting, companies are scrambling to find so-called technical accountants, regulatory experts who can understand the rules and ensure that management and staff comply.

Large companies can outsource the work to big accounting firms but would prefer to have their own expertise to maintain internal standards as regulators pay more attention to corporate-accounting practices, said Mr. Rivera.

“It’s a question of creating bench strength,” he said.

The unemployment rate for experienced accountants and auditors was 2.5% in 2016, compared with the overall rate of 4.4% for experienced workers, according to the Bureau of Labor Statistics. The jobless rate for accountants has come down steadily from 4.2% in 2011, the earliest year during which the BLS adopted new job classifications.

“Based on the unemployment rate, it’s going to be harder for everybody to fill a job,” said Paul McDonald, a senior executive director at staffing firm Robert Half International Inc.

Increasingly, the companies are competing for talent with major accounting and audit firms that had once served as a reliable pipeline for corporate finance back offices.

Some of the firms have changed their work culture in a bid to keep workers happy and keep them longer. When Len Combs started working at accounting and consulting firm PricewaterhouseCoopers LLP in 1992, long hours at the office were the norm, and work-life balance wasn’t a priority.

“The idea was, if you don’t like it, go do something else,” said Mr. Combs, now U.S. chief auditor for the firm. Accordingly, many young associates quit and took jobs in corporate-finance departments at public companies.

PwC has recently lowered its turnover rates, in part by allowing associates to work from home and permitting them more flexible hours. Employees also get perks at the office such as treadmill desks, and Ping-Pong and foosball tables.

Turnover in the company’s audit and compliance group for employees who had been there three to five years fell to 20% last year from 26% in 2014, according to a PwC report.

The shrinking pool of available accountants is putting pressure on companies as they begin to apply new Financial Accounting Standards Board rules. The changes affect the way firms book revenue and report the value of leases held on their balance sheets. The rules don’t take effect right away: Public companies must apply new revenue standards for fiscal years beginning after Dec. 15, and new lease rules begin in 2019. Still, corporations must assess and revise two years of past financial reports.

“There is a demand for technical expertise, absolutely,” said Robert Grecco, controller at luxury fashion brand Ralph Lauren Corp. “And that demand is only going to increase.”

Mr. Grecco has four technical accountants on his team. He is paying them annual salaries ranging from $150,000 to more than $250,000. The median salary for accountants and auditors in the U.S. was $67,190 a year, according to the of Labor Statistics.

Enrollment in accounting programs hit a record in 2014, surpassing 250,000 for the first time since at least the 1993-94 school year, according to a study by the American Institute of CPAs, a trade group.

Many accounting firms are plucking undergraduates soon after they complete their degrees, said Pat Hopkins, chair of the graduate accounting programs at Indiana University’s Kelley School of Business.

The school’s enrollment in undergraduate accounting programs rose more than 10% between 2012 and 2016, he said. That could partly be explained by aggressive efforts by schools and accounting firms to market accounting as a career.

The number of accounting graduates hired by accounting firms surged to a record 43,252 in 2014, the most recent year for which the AICPA has statistics. That represented a 7% jump from 2012, when the group conducted its prior study.

PwC has started outreach efforts to entice high-school students to enter accounting programs at college. This suggests the accountant shortage, while immediate, may not be a long-term problem. “The pipeline is full,” said Mark Koziel, executive vice president for firm services at the AICPA.

Write to Vipal Monga at vipal.monga@wsj.com