Worm-like robots have demonstrated great potential in navigating through environments requiring body shape deformation. Some examples include navigating within a network of pipes, crawling through rubble for search and rescue operations, and medical applications such as endoscopy and colonoscopy. In this work, we developed path planning optimization techniques and obstacle avoidance algorithms for the peristaltic method of locomotion of worm-like robots. Based on our previous path generation study using a modified rapidly exploring random tree (RRT), we have further introduced the Bézier curve to allow more path optimization flexibility. Using Bézier curves, the path planner can explore more areas and gain more flexibility to make the path smoother. We have calculated the obstacle avoidance limitations during turning tests for a six-segment robot with the developed path planning algorithm. Based on the results of our robot simulation, we determined a safe turning clearance distance with a six-body diameter between the robot and the obstacles. When the clearance is less than this value, additional methods such as backward locomotion may need to be applied for paths with high obstacle offset. Furthermore, for a worm-like robot, the paths of subsequent segments will be slightly different than the path of the head segment. Here, we show that as the number of segments increases, the differences between the head path and tail path increase, necessitating greater lateral clearance margins.