Add lines to startup so they run automatic

i need this line to run at start up on octoprint

python3 /home/pi/stats.py &

where do i put it

Please tell us what operating system (I assume some flavor of Linux).

You probably want to use systemd. Here's one link to get you started.