> why does the UDP datagram header contain a space for a source port?

Ports are a concept of the transport-layer protocol (L4). Not all those protocols use ports but the most common ones, TCP and UDP do.

There are no ports on the network layer (IP), so it wouldn't make sense to put that field in the IP header.

> how does the application layer know what IP to respond to if the IP header has been stripped?

The IP header isn't visible to the application but its information is. The OS stack provides an API for the application to use, usually BSD-style sockets. That API also provides information about a connection partner's IP and L4 port.