The electric potential at A and B are denoted by V(A)
and V(B) respectively Since current is flowing from A to B, V(A) > V(B)
and the potential difference across  AB is V = V(A) – V(B) > 0 In a time interval Dt, an amount of charge DQ = I Dt travels from A to
B The potential energy of the charge at A, by definition, was Q V(A) and
similarly at B, it is Q V(B)