You have 2 separate transactions:
1. You borrow on your home loan to invest in shares
2. You deposit from a different source other funds into an offset account
Provided the offset is not against the funds you borrowed for investing, interest on your borrowing will still be deductible...