They are called "anti shock bodies" or "Kuchermann Carrots" and can serve two purposes...

They are often used as a streamlined housing for flap tracks and actuators (Boeing 747, 757, 767, 777)

They also smooth out the cross sectional area to reduce transonic drag. (Convair 990)