Facebook Inc.’s news feed is running out of room for advertisements, but the social media giant is making up for it with higher prices and new slots for ads in videos and its messaging apps.

The company on Wednesday said profit spiked 71% in the second quarter. While growth is still rapid, Facebook warned that the number of ads in the news feed—its primary source of revenue—is hitting a ceiling.

Facebook...