Pavia is about 25 minutes by train from Milano. The train schedule is available here
If you fly to Milano Linate, the best option is to take the Line 4 subway to Milano Dateo, and from there a local train (S13) to Pavia. Please note that the Dateo train station is underground.
If you fly to Milano Malpensa, the best way to reach Pavia is to take the Malpensa Express train to Milano Centrale or Milano Porta Garibaldi and from there a train to Pavia. The Malpensa Express train schedule is available here. Note that the Trenitalia website distinguishes between "Milano Porta Garibaldi" and "Milano Porta Garibaldi Passante", but they are the same station, and "Passante" denotes the underground part. Another option is to take a shuttle to the Milano Centrale Train Station and then take a local train to Pavia. Here is the shuttle schedule.
If you fly to Orio al Serio (Ryanair airport), the best thing is to take a bus to the Milano Centrale train station and then a train to Pavia.