Your iPhone will only sync photos with iCloud if you turn that option on. See: Set up and use iCloud Photos - Apple Support
The same is true for your Mac.
You can turn iCloud Photos on in one device or both. Only the device(s) turned on will sync.
Also note that even if you turn iCloud Photos on, your photos will still be on the device(s). There is an option where you can reduce the storage needed by turning on the Optimize option. See above support article. If that option is on, your iPhone or Mac may have smaller optimized versions of some or all photos to save space. If you don't turn that option on, your device will have the full size originals event though they are also synced with iCloud.