The Walther P-38/P1 is an "odd" design in that it ejects to the LEFT, instead of the "normal" right.
Having an occasional case thrown at your head is not uncommon with these guns.
Your first step would be to give the entire gun a thorough cleaning and lubing.
Pay special attention to getting the extractor assembly clean.
Many of these guns were packed in heavy lube and haven't been really cleaned in 30 years.
Impacted, dried lube in the extractor assembly can cause weak ejection.
Inspect the extractor for wear, chips, or other damage.
Make sure it has plenty of spring tension after it's cleaned.
Inspect the ejector to insure it's not bent, worn, or deformed.
Also, be sure to clean the magazine. Many odd problems with these guns are "cured" after the magazine is cleaned.
Magazines especially are often gummed up.
If this doesn't do it, have a gunsmith replace the extractor spring, and possibly the extractor and ejector.