$\newcommand{\Ex}{\mathbb E} \newcommand{\diff}{~\mathrm d}$Recently, I have read the integration by parts formula for a continuous semi-martingale in these notes.
Theorem Let $X$ and $Y$ be continuous semi-martingales such that $$ \Ex \bigg [ \int_0^t (X_s + Y_s)^2 \diff \langle X + Y \rangle_s \bigg ] <\ \infty \quad \forall t \ge 0. \quad \quad (\star) $$ Then $$ X_t Y_t - X_0 Y_0 = \int_0^t X_s \diff Y_s + \int_0^t Y_s \diff X_s + \langle X, Y \rangle_t \quad \text{a.s.} \quad \forall t \ge 0. $$ Proof Let $f(x):=x^2$. Then $f'(x) = 2x$ and $f''(x)=2$ for all $x \in \mathbb R$. Notice that $Z _t :=X_t+Y_t$ is a continuous semi-martingale. By Itô's lemma, $$ \begin{align} (X_t+Y_t)^2 - (X_0+Y_0)^2 &= 2 \int_0^t (X_s+Y_s) \diff (X_s+Y_s)+\langle X+Y\rangle_t, \\ (X_t-Y_t)^2 - (X_0-Y_0)^2 &= 2 \int_0^t (X_s-Y_s) \diff (X_s-Y_s)+\langle X-Y\rangle_t. \end{align} $$ Subtracting these two formulas gives: $$ 4 X_t Y_t-4 X_0 Y_0=4 \int_0^t X_s \diff Y_s+4 \int_0^t Y_s \diff X_s + (\underbrace{\langle X+Y\rangle_t - \langle X-Y\rangle_t}_{=4\langle X, Y\rangle_t} ), $$ which completes the proof.
The integrability condition $(\star)$ is imposed so that the required hypothesis of Itô's lemma is satisfied.
Can $(\star)$ be weakened in a way that the integration by parts still holds?
Related definition: Let $(\Omega, \mathcal F, \mathbb P)$ be a probability space and $\mathfrak F = (\mathcal{F}_t, t \ge 0)$ a filtration.
Let $M$ be a continuous square-integrable martingale w.r.t. $\mathfrak F$. Then $M^2$ is a continuous sub-martingale w.r.t. $\mathfrak F$. By Doob's decomposition theorem, there exists a unique continuous increasing process $\langle M \rangle$ adapted to $\mathfrak F$ such that $\langle M \rangle_0 = 0$ a.s. and that $M^2 - \langle M \rangle$ is a continuous martingale w.r.t. $\mathfrak F$. Then $\langle M \rangle$ is called the quadratic variation of $M$.
A process $X$ is called a continuous semi-martingale w.r.t. $\mathfrak F$ is that can be written as $X_t = M_t+V_t$ where
- $M$ is a continuous square-integrable martingale w.r.t. $\mathfrak F$.
- $V$ is a continuous process that has bounded variation and is adapted to $\mathfrak F$ such that $V_0 = 0$ a.s.
Then the quadratic variation of $X$ is defined as $$ \langle X \rangle := \langle M \rangle. $$
Let $H$ be a continuous adapted process such that $$ \mathbb E \bigg [ \int_0^t H_s^2 \mathrm d \langle X \rangle_s \bigg ] < \infty \quad \forall t\ge 0. $$
Then the stochastic integral of $H$ with respect to $X$ is defined as $$ (H \cdot X)_t := \int_0^t H_s \mathrm d X_s := \underbrace{\int_0^t H_s \mathrm d M_s}_{\text{Itô's integral}} + \underbrace{\int_0^t H_s \mathrm d V_s}_{\text{Riemann-Stieltjes's integral}}. $$
Itô's lemma. Let $X$ be a continuous semi-martingale and $f:\mathbb R \to \mathbb R$ twice continuously differentiable such that $$ \mathbb E \bigg [ \int_0^t (f'(X_s))^2 \mathrm d \langle X \rangle_s \bigg ] < \infty \quad \forall t\ge 0. $$ Then for all $t \ge 0$, $$ f(X_t)-f(X_0) = \int_0^t f'(X_s) \mathrm d X_s + \frac{1}{2} \int_0^t f''(X_s) \mathrm d \langle X \rangle_s \quad \text{a.s.} $$