Equality of integrals and Almost sure equality of random variables Given two random variables X,Y with $E |X|<\infty$, $E |Y|<\infty$ and the equality 
$$\int_{D}X dP=\int_{D}Y dP, D\in\mathcal{D}$$
where $\mathcal{D}$ is some sigma algebra on the background space.
What are the sufficient conditions so that we can conclude that $X$ and $Y$ are almost surely equal?
Likewise, if we have two random variables that are almost surely equal, do we have the equality in the integrals above in general?
 A: This is quite a standard argument in measure theory. You don't need any additional assumptions (if I understand it correctly that you suppose the equality holds for all $D$ in the $\sigma$-algebra).
You can easily reduce the problem to the setting 
$$\int_D X dP=0 $$
for all $D\in \mathcal{D}$ by taking the difference of $X$ and $Y$ (both sides are finite by your assumption) and we will show that $X=0$ almost surely in that case.
Let $A_n:=\{\omega:X(\omega)>\frac{1}{n}\}$. If for any $n\in \mathbb{N}$ the set $A_n$ has nonzero probability we obtain the contradiction
$$\int_{A_n} X dP\geq \frac{P(A_n)}{n}>0.$$
Therefore, $P(A_n)=0$ for all $n$.
Furthermore, we have 
$$A:=\{\omega:X(\omega)>0\}=\bigcup_{n\in \mathbb{N}}A_n$$
and by the $\sigma$-subadditivity this implies $P(A)=0$.
With the same argument we also obtain $P(\{\omega:X(\omega)<0\})=0$ and, thus, $P(\{\omega:X(\omega)\neq 0\})=0$ which is equivalent to $X= 0$ almost surely.
For the other direction note that you can always disregard sets of measure zero in interals due to the convention $\infty \cdot 0=0$, i.e., you can always take the integrals only over the set where the two functions coincide and there the integrals are trivially equal.
