Foreigners boosted their direct investment in American companies by 23 percent last year, after a similar rise in 1978. The increases in the last two years were double the average for the preceding three years.

The net book value of foreign direct investments in and loans to their U.S. affiliates totaled $52.3 billion at the end of 1979, according to a report issued yesterday by the CommerceDepartment.

U.S. direct investment overseas still far exceeds that of foreigners in this country, however. The net book value of American overseas investment and loans climbed 15 percent in 1979 and reached $192.6 billion by the end of the year.

The biggest increase in direct U.S. investment overseas was in petroleum activities. This rose by 23 percent in1979 to $41.55 billion after a 7 1/2 percent rise the privious year. Reinvested earnings in petroleum affiliates more than tripled during 1979. Anotherfactor contributing to the increase in oil investment was that U.S. companies stepped up their payments to Middle East oil affiliates because these had shortened their credit terms for purchasers of crude oil, in accordance with host-government requests.

American investment in overseas manufacturing and "other" industries went up by 13 percent last year, the report said. The net book value of the manufacturing investments and loans totaled $83.56 billion at the end of 1979.

U.S. investment in developed countries went up 18.4 percent in 1979 to $47.8 billion, while investment in developed countries rose by 14 1/2 percent to $38.7 billion.

A foreign affiliate is a foreign enterprise in which a single U.S. direct investor has at least 10 percent of the voting securities, while a U.S. affiliate is an American firm in which a single foreign investor owns at least 10 percent of the voting securities.

American parent companies' income from their overseas investments increased by 50 percent last year, to $37.8 billion. Rising income from oil affiliates accounted for 60 percent of the overall earnings increase.