$dU$ usually refers exclusively to the change in internal energy of the system, though you do bring up a common point about internal and external pressures. I will use the convention that positive work $W$ means work done on the gas by the surroundings.
The equation that is always correct is $W = -\int P_{ext} dV$, no matter whether the process is reversible or not. So the following formulation is also always correct
$dU = Q + W = Q - \int P_{ext} dV$
The problem is that "internal pressure" is often not well defined. If the process is reversible - that is, a continuous series of equilibrium states - then the internal pressure is fairly well defined by the ideal gas equations, and we can use an internal pressure of $P_{int} = \frac{nRT}{V}$. In this case, due to the equilibrium condition, $P_{ext} = P_{int}$ and it is perfectly fine to write $W = -\int P_{int} dV$.
However, if the process is not reversible, contributions from (for instance) viscous stresses also affect the force per unit area at the interface and the internal pressure we might calculate from the ideal gas equations does not equal the force per unit area at the interface. The external pressure, however, is well defined and consequently we can use this in our calculations.
To summarise, if in doubt always use $W = -\int P_{ext} dV$, unless you are completely sure the process is reversible (in which case you can use the internal pressure).
Extra Note
You might wonder why the equation for external pressure is valid. To give some explanation, consider a piston expanding non-reversibly from one rest position to another rest position. The internal pressure is not well defined, so let's call the work done by the inside gas on the piston between the start and end positions $W_{p}$. The external pressure is well defined, so let's call the work done by the surroundings on the piston $-\int P_{ext} dV$.
Since the total work done on the piston between the start and end positions equals the piston's change in kinetic energy (zero!), we have
$W_{p} - \int P_{ext} dV = 0 \implies W_{p} = \int P_{ext} dV$
Finally, since $W_{p}$ is the work done by the inside gas on the piston, the work one by the piston on the inside gas, $W$ then equals
$W = -W_{p} = -\int P_{ext} dV$