BOSTON—The Boston Police Department is taking heat from civil liberty groups for plans to spend up to $1.4 million on new software that scours social media and the internet for potential threats.

The attack Monday on the Ohio State University campus is just the latest illustration of why local law enforcement authorities need every tool they can muster to stop terrorism and other violence before it starts, according to Boston Police Commissioner William Evans.

Monitoring...