I inject drugs, is there a way for me to decrease my chances of contracting endocarditis?

Yes. Never reuse a syringe - use disposables only. Clean your skin with alcohol prior to injection. Just like is done at the hospital. Be as certain as you can that the material you're injecting is sterile.
Not really. Iv drug users are at increased risk for endocarditis, and I am not aware of any intervention that has been shown to decrease that risk. The healthiest thing to do is to seek help to stop using injection drugs altogether. Clean needles and cleaned injection sites are better than the alternative, but cannot eliminate or adequately control the numerous, life threatening risks of this practice.