Instead of telling young children what NOT to do, teach them what they CAN do.
Demonstrating the action along with the words is most effective. For example, instead of "Don't hit," say "Gentle touches," while you take their hand and demonstrate. Then reinforce the lesson by asking them to show you their gentle touches.
If you have a rule about not throwing balls in the house, then you can teach them what to do with the ball in the house instead of throwing it. Perhaps rolling it on the floor is acceptable to you. Show them how to roll it on the floor and play a few rounds of pass it back and forth to reinforce the lesson.
If the child later forgets and throws instead of rolls, do another round of reminding and practicing. Or, you can say, "Looks like you're having trouble remembering to roll the ball instead of throw it. How about we go outside together and throw for a while?" Or put the ball away for the time being and redirect to a totally different activity.
Throwing is often a seemingly irresistible action to your child. After all, toddlers have a strong drive to achieve developmental milestones and experiment with the world around them, and throwing is part of that. So it might be a good idea to provide them something that they CAN throw indoors without the worry of breaking something. Something not very aerodynamic may fit the bill, like a small bean bag or a lightweight foam ball.